I was involved with different kinds of Django projects in the past. Back then the standard approach of attaching your debug interpreter was by creating a virtual environment in your python project. We debugged using PyCharm at that time. JetBrains generously gave us a free licence to use the whole suite of JetBrains tools as their way of supporting open source projects.
Viewing posts for the category Python
Reading and Writing XLSX File with Openpyxl
Openpyxl is a Python library used for manipulating Excel files. I came across a ticket that required exporting data to XLSX format, and I used Openpyxl for that as it’s pretty straightforward.
Python is a dynamically-typed language, which means the interpreter does type-checking when the code is executed, and the variable type can change over its lifetime.
Making Django Custom Migrations
Working with Django, we must be familiar with
makemigrations and the
migrate command. We use
makemigrations to automatically generate migration files, and
migrate to apply them.
Python Mocking Introduction
Mocking is a process in unit testing when the test has external dependencies. We isolate our code during the test, without having to worry about the unexpected behavior of the dependencies. For example, we create a routine to save something to Firebase which utilizes 3rd party library called Firestore. There could be problems when saving data to Firebase, like internet connections, wrong configuration, non-existing document, you name it. Instead of testing every possible scenario when saving to Firebase, we only test that Firestore is called with correct parameter, which represents our data. The tests for Firestore itself should have been done by Firestore developer. Hence, we can shift our focus towards the implementation of our code. It also reduces testing time because we don’t need to send our data to Firebase.
Using a Docker Compose-Based Python Interpreter in PyCharm
Working with Web Data using Requests and Beautiful Soup
Imagine us in charge of developing a feature to show public data coming from a third party that doesn’t have an API. Let’s say, we need to show current and historical data of dam water level which we can access at http://www.dwa.gov.za/Hydrology/Weekly/ProvinceWeek.aspx?region=WC. We cannot possibly add the entry manually--it’s too time consuming. Some of us might choose the hard way to ask the data provider to make a public API, but there is a time constraint as we need it as soon as possible. One way to solve this is to use a method called “web scraping”.
Mocking Requests with requests_mock
Testing is an important part of software development, be it manual or automated. Untested code is a ticking time bomb ready to explode at the worst time possible, hence each developer must be responsible for testing their code. It’s even better when they make automated tests for their code, even if it’s only unit tests.
Speeding up multiple web map service requests using Python's asyncio and aiohttp
Geocontext is a Django app that retrieves information from multiple web based services for a specific query point. The services are arranged into hierarchies with multiple services in a group and multiple groups in a collection. It currently supports querying WMS, WFS & ArcREST services.
Calculating intersects for map layers and map extent dynamically in QGIS
Recently we have been working on a project that involves simulating the 1 in 50k topographic maps in South Africa. Since we are using QGIS Server to print the map all the logic is set up in print composer. All maps generated are dynamic (users can select a specific area within South Africa to print) and QGIS Server will use the map template to generate the map.
FOSS4G 2019 and QGIS in Bucharest
Open source GIS is alive and well and continues to grow in leaps and bounds around the world. Why so many Government entities in South Africa continue paying a fortune of tax-payers money for privative GIS and database software beats me, when wealthy, developed countries (as in most of Europe, for example) saw the light years ago and enthusiastically embrace FOSS.