Feeds

Gregor Herrmann: demo video: dpt(1) in pkg-perl-tools

Planet Debian - Sat, 2023-02-25 17:36

in the Debian Perl Group we are maintaining a lot of packages (around 4000 at the time of writing). this also means that we are spending some time on improving our tools which allow us to handle this amount of packages in a reasonable time.

many of the tools are shipped in the pkg-perl-tools package since 2013, & lots of them are scripts which are called as subcommands of the dpt(1) wrapper script.

in the last years I got the impression that not all team members are aware of all the useful tools, & that some more promotion might be called for. & last week I was in the mood for creating a short demo video to showcase how I use some dpt(1) subcommands when updating a package to a new upstream release. (even though I prefer text over videos myself :))

probably not a cinematographic masterpiece but as the feedback of a few viewers has been positive, I'm posting it here as well:

(direct link as planets ignore iframes …)

Categories: FLOSS Project Planets

Jelmer Vernooij: Silver Platter Batch Mode

Planet Debian - Sat, 2023-02-25 16:44
Background

Silver-Platter makes it easier to publish automated changes to repositories. However, in its default mode, the only option for reviewing changes before publishing them is to run in dry-run mode. This can be quite cumbersome if you have a lot of repositories.

A new “batch” mode now makes it possible to generate a large number of changes against different repositories using a script, review and optionally alter the diffs, and then all publish them (and potentially refresh them later if conflicts appear).

Example running pyupgrade

I’m using the pyupgrade example recipe that comes with silver-platter.

--- name: pyupgrade command: 'pyupgrade --exit-zero-even-if-changed $(find -name "test_*.py")' mode: propose merge-request: commit-message: Upgrade Python code to a modern version

And a list of candidate repositories to process in candidates.yaml.

--- - url: https://github.com/jelmer/dulwich - url: https://github.com/jelmer/xandikos

With these in place, the updated repositories can be created:

$ svp batch generate --recipe=pyupgrade.yaml --candidates=candidate.syml pyupgrade The intermediate results

This will create a directory called pyupgrade, with a clone of each of the repositories.

$ ls pyupgrade batch.yaml dulwich xandikos $ cd pyupgrade/dulwich $ git log commit 931f9ffb26e9143c56f20e0b85e6ddb0a8eee2eb (HEAD -> master) Author: Jelmer Vernooij <jelmer@jelmer.uk> Date: Sat Feb 25 22:28:12 2023 +0000 Run pyupgrade diff --git a/dulwich/tests/compat/test_client.py b/dulwich/tests/compat/test_client.py index 02ab6c0a..9b0661ed 100644 --- a/dulwich/tests/compat/test_client.py +++ b/dulwich/tests/compat/test_client.py @@ -628,7 +628,7 @@ class HTTPGitServer(http.server.HTTPServer): self.server_name = "localhost" def get_url(self): - return "http://{}:{}/".format(self.server_name, self.server_port) + return f"http://{self.server_name}:{self.server_port}/" class DulwichHttpClientTest(CompatTestCase, DulwichClientTestBase): ...

There is also a file called batch.yaml that describes the pending changes:

1 2 3 4 5 6 7 8 9 10 11 12 13name: pyupgrade work: - url: https://github.com/dulwich/dulwich name: dulwich description: Upgrade to modern Python statements commit-message: Run pyupgrade mode: propose - url: https://github.com/jelmer/xandikos name: xandikos description: Upgrade to modern Python statements commit-message: Run pyupgrade mode: propose recipe: ../pyupgrade.yaml

At this point the changes can be reviewed, and batch.yaml edited as the user sees fit - they can remove entries that don’t appear to be correct, edit the metadata for the merge requests, etc. It’s also possible to make changes to the clones.

Once you’re happy, publish the results:

$ svp batch publish pyupgrade

This will publish all the changes, using the mode and parameters specified in batch.yaml.

batch.yaml is automatically stripped of any entries in work that have fully landed, i.e. where the pull request has been merged or where the changes were pushed to the origin.

To check up on the status of your changes, run svp batch status:

$ svp batch status pyupgrade

To refresh any merge proposals that may have become out of date, simply run publish again:

svp batch publish pyupgrade
Categories: FLOSS Project Planets

Petter Reinholdtsen: OpenSnitch available in Debian Sid and Bookworm

Planet Debian - Sat, 2023-02-25 14:30

Thanks to the efforts of the OpenSnitch lead developer Gustavo Iñiguez Goya allowing me to sponsor the upload, the interactive application firewall OpenSnitch is now available in Debian Testing, soon to become the next stable release of Debian.

This is a package which set up a network firewall on one or more machines, which is controlled by a graphical user interface that will ask the user if a program should be allowed to connect to the local network or the Internet. If some background daemon is trying to dial home, it can be blocked from doing so with a simple mouse click, or by default simply by not doing anything when the GUI question dialog pop up. A list of all programs discovered using the network is provided in the GUI, giving the user an overview of how the machine(s) programs use the network.

OpenSnitch was uploaded for NEW processing about a month ago, and I had little hope of it getting accepted and shaping up in time for the package freeze, but the Debian ftpmasters proved to be amazingly quick at checking out the package and it was accepted into the archive about week after the first upload. It is now team maintained under the Go language team umbrella. A few fixes to the default setup is only in Sid, and should migrate to Testing/Bookworm in a week.

During testing I ran into an issue with Minecraft server broadcasts disappearing, which was quickly resolved by the developer with a patch and a proposed configuration change. I've been told this was caused by the Debian packages default use if /proc/ information to track down kernel status, instead of the newer eBPF module that can be used. The reason is simply that upstream and I have failed to find a way to build the eBPF modules for OpenSnitch without a complete configured Linux kernel source tree, which as far as we can tell is unavailable as a build dependency in Debian. We tried unsuccessfully so far to use the kernel-headers package. It would be great if someone could provide some clues how to build eBPF modules on build daemons in Debian, possibly without the full kernel source.

As usual, if you use Bitcoin and want to show your support of my activities, please send Bitcoin donations to my address 15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b.

Categories: FLOSS Project Planets

Holger Levsen: 20230225-Debian-Reunion-Hamburg-2023

Planet Debian - Sat, 2023-02-25 11:19

Debian Reunion Hamburg 2023 from May 23 to 30

As in the last years there will be a Debian Reunion Hamburg 2023 event taking place at the same location as previous years, from May 23rd until the 30th (with the 29th being a public holiday in Germany and elsewhere).

This is just a short announcement to get the word out, that this event will happen, so you can ponder and prepare attending. The wiki page has more information and some fine folks have even already registered! Announcements on the appropriate mailinglists will follow soon.

And once again, a few things still need to be sorted out, eg a call for papers and a call for sponsors. Also this year I'd like to distribute the work on more shoulders, especially dealing with accomodation (there are 34 beds available on-site), accomodation payments and finances in general.

If you want to help with any of that or have questions about the event, please reach out via #debconf-hamburg on irc.oftc.net or via the debconf-hamburg mailinglist.

I'm very much looking forward to meet some of you once again and getting to know some others for the first time! Yay.

Categories: FLOSS Project Planets

Consensus Enterprises: Aegir5 Development is Happening!

Planet Drupal - Sat, 2023-02-25 09:00
Aegir5 development is happening! We (Consensus) have been making steady progress on it over the last few years and are looking to kick off a new burst of focused development. Here’s a summary of progress that has been made so far and how you can contribute. First off, as you’re probably aware, Aegir5 is a complete re-write of Aegir. We are intending to build on all the great aspects of Aegir, while freeing ourselves from a codebase that is rooted in PHP 4.
Categories: FLOSS Project Planets

ComputerMinds.co.uk: Drupal 10 upgrade: Defining the project scope

Planet Drupal - Sat, 2023-02-25 01:19

Let's define the scope and goals of our project to upgrade this very website to Drupal 10.

Essentially, that's it: we want to upgrade this website to Drupal 10 so that we can benefit from security releases etc. At the moment we want to do so with the minimum of effort, so I don't want to have to be writing lots and lots of code or changing fundamentally how the site works, but I am up for simplifying things if it gets us to a point where we have to maintain less code.

Since Drupal 9, major version upgrades now take this basic form:

  • Update your code to be fully compatible with the last version of Drupal, removing all deprecations: hard.
  • Upgrade to the new version of Drupal: easy!

I'm going to install and use the fantastic Upgrade Status module to get a detailed handle on what we need to change, upgrade and rewrite to get the site working in Drupal 9, but ready for Drupal 10. We'll use that as a basis to see what we need to upgrade, the best plan for each component and go from there.

Upgrade status - First pass

We previously have composer require'd the upgrade status module into our codebase, so after enabling and running the report, here are the major findings that concern us for this series:

Environment
  • We'll need to upgrade to PHP 8.x, the site is currently running on PHP 7.4.
  • We're using deprecated or obsolete modules that come with core and will be removed in Drupal 10. This is a rather scarily long list for us:
    • CKEditor
    • Color
    • RDF
    • Seven
    • Stable

But other than that, we're good to go from an environment point of view.

Contrib projects

Upgrade status breaks the list of contributed projects down into a few sections, those are:

  • Projects that need an upgrade that might make them Drupal 10 compatible:
    • Better exposed filters
    • Components
    • Disqus
    • Advanced link
    • Entity browser
    • jQuery UI Slider
    • Scheduler
    • Simple XML Sitemap
    • Twig Tweak
    • Webform
  • Projects that don't have Drupal 10 releases yet, so either require patches or work to get them to Drupal 10:
    • Entity Embed
    • jQuery UI Sortable
    • Kraken
    • Markdown
    • Social media share
    • Term Reference Change
    • Unified Twig Extensions
    • Video Embed HTML5
    • Weight
  • Projects that are compatible with Drupal 10 already, I'll not list those, but there are plenty already, it's great to see community support for Drupal 10.
Custom code

Upgrade status will scan your code and tell you if there are problems that can be spotted that will stop the code working with Drupal 10. This is static analysis, so isn't perfect, but is a really good start. We have a few custom modules doing very specific things on our site, but we have a custom theme, doing quite a lot of custom things, and that's where the main bulk of the issues the scanner found are, so we're going to need to set aside some time for that.

Simplifications

This site was built in the early Drupal 8 days, and we've not actually made too many changes since, specifically when we upgraded to Drupal 9 we basically did the smallest amount of work to get it there. How you'd typically handle media on a Drupal site has fundamentally changed since we built this site, in that you'd likely use the core Media module and add entity reference fields to your entities rather than adding image/file fields directly. However, we never had that luxury and never got around to changing our approach to use the core Media framework.

So, we're going to allow ourselves a bit of scope creep to do this 'sub project' given that the benefits are that we're going to be able to remove a bunch of modules: entity browser, file browser, etc. that will then mean that we don't need to upgrade those modules and our dependencies will be better supported: since they'll be in Drupal core. It's no slight against those modules, it's just that we don't need the functionality they bring, for our site today.

The scope/plan

So roughly the scope/plan is shaping up to be:

  1. Convert our file/image fields to core media, and remove entity browser, file browser, etc.
  2. Update our custom code
  3. Evaluate the remaining upgradeable contrib projects to see if we can remove them, and if not, upgrade them.
  4. Evaluate the remaining non-upgradeable contrib projects to see if we can remove them, and if not, work with maintainers to get them upgraded.
  5. Handle the core modules that have been marked as deprecated or obsolete.
  6. Upgrade the PHP version we use to run the site
  7. Get the site running in tip-top condition with the latest Drupal 9 etc.
  8. Do the Drupal 10 upgrade.

Then we'll have a shiny Drupal 10 install, ready for the next few years of security patching.

Categories: FLOSS Project Planets

This week in KDE: even better multi-monitor

Planet KDE - Fri, 2023-02-24 23:45

Something funny happens when you take something that was super broken and you make it work a lot better: people start to use it more! And then they submit bug reports for all their unusual use cases that you failed to anticipate or that hadn’t been getting exercised in a long time. So in the short term it looks like things are worse, but in fact they’re better because the bug reports are becoming about more and more exotic use cases over time.

I saw this happen starting 2 years ago with the Plasma Wayland session (which has since become very robust), and now it’s happening again with multi-monitor setups. We finally nailed the basics, so people are trying it out again, abandoning their xrandr hackaround scripts, and submitting bug reports about the issues with their wild and wacky screen arrangements. And this is great! So we spent a ton of time this week working on fixing all those edge case bugs to make our new multi-monitor system even more robust. With a strong foundation, fixing the bugs isn’t that hard!

And while the core Plasma team worked on those things, a lot of great work also was done by everyone else to add features and polish the user interface! So there’s lots to see this week:

New Features

Using the context menu item present in Dolphin and the desktop, you can now set an image to be the wallpaper for the lock screen too, or for both the desktop and the lock screen at the same time! (Julius Zint, Plasma 6.0. Link):

Ignore the fact that there are two “Set as Wallpaper” menu items; this is a bug that will be fixed soon User Interface Improvements

Kate and KWrite now internally save their set of open documents shortly after they’re opened, so if either app crashes or gets killed due to memory pressure, you won’t lose your open documents when you re-open it anymore (Waqar Ahmed, Kate & KWrite 23.04. Link)

Okular now zooms smoothly rather than in steps when you Ctrl+scroll using a touchpad or a high-resolution scroll wheel (Friso Smit, Okular 23.04. Link)

When setting up a new Plasma system, apps that are pinned to the Task Manager by default in Plasma (Discover, System Settings, Dolphin, and a web frowser) but not actually installed by default on the operating system you’re using will now simply be omitted, instead of remaining visible with a broken icon and doing nothing when clicked (Fushan Wen, Plasma 5.27.2. Link)

Welcome Center has received a visual overhaul to bring it more in line with other KDE apps, so now its interactive buttons appear in a footer and there are dots showing all pages and which page is active (Oliver Beard, Plasma 6.0. Link 1 and link 2):

Discover’s application page has received yet another visual overhaul, making better use of space, reducing redundancy, and looking better overall (me: Nate Graham, Plasma 6.0. Link):

System Settings’ Flatpak Permissions page now includes a search field for the apps list and a pretty header for the apps details pane (Ivan Tkachenko, Plasma 6.0. Link):

Significant Bugfixes

(This is a curated list of e.g. HI and VHI priority bugs, Wayland showstoppers, major regressions, etc.)

Fixed a recent regression that could cause Plasma could crash when waking up the system while using a multi-screen arrangement (Aleix Pol Gonzalez, Plasma 5.27.1. Link)

Found a better way to fix incorrect scaling in the Plasma Wayland session for XWayland-using Electron apps that does not result in any regressions, and also fixes scaling in Steam, too! (Luca Bacci and Fushan Wen, Plasma 5.27.1. Link 1 and Link 2)

Fixed a recent regression that caused line artifacts to appear around panels when using a fractional scale factor in the Plasma Wayland session (Arjen Hiemstra, Plasma 5.27.2. Link)

Fixed a case where KWin could crash in the Plasma Wayland session while a video was playing in VLC (Vlad Zahorodnii, Plasma 5.27.2. Link)

Fixed a case where KWin could crash while logging out of a Plasma Wayland session and leave you hanging (Vlad Zahorodnii, Plasma 5.27.2. Link)

When using the recently-released version 1.8.11 or later of the fwupd library, Discover will now always launch properly (Adam Williamson, Plasma 5.27.2. Link)

Fixed a recent regression that could cause powerdevil to crash with certain multi-screen arrangements, breaking power management (Aleix Pol Gonzalez, Plasma 5.27.2. Link)

Fixed a case where System Settings could crash while applying or reverting screen arrangement changes (Arjen Hiemstra, Plasma 5.27.2. Link)

Fixed a major recent regression in how Aurorae window decoration themes were drawn in the Plasma Wayland session (David Edmundson, Plasma 5.27.2. Link 1 and link 2)

Fixed a semi-recent regression in the Plasma Wayland session that allowed the cursor to briefly go 1 pixel beyond the screen on the bottom and right screen edges, somewhat breaking Fitts’ Law and causing hover-enabled UI elements on screen edges to flicker (Xaver Hugl, Plasma 5.27.2. Link)

Fixed an issue in the Plasma Wayland session where desktop size would be computed subtly incorrectly when using a fractional scale factor and cause various off-by-one-pixel visual and functional glitches all over the place (David Edmundson, Plasma 5.27.2. Link)

Discover no longer shows complete nonsense for most distro-repo-provided apps in the “Distributed by:” field on app pages (me: Nate Graham, Plasma 5.27.2. Link)

The semi-new QML version of the Present Windows effect now works properly with the keyboard when invoked in its mode that only shows the windows of a specific app, no longer allowing you to invisibly focus windows of other apps too (Vlad Zahorodnii, Plasma 5.27.2. Link)

When using a fractional scale factor in the Plasma Wayland session, the cursor is now rendered correctly in XWayland-using apps (Xaver Hugl, Plasma 5.27.2. Link)

Multi-screen arrangements consisting of screens from the same vendor that differ by only the last character of their serial numbers (imagine a large company buying monitors in bulk) will no longer get scrambled on login (David Redondo, Plasma 5.27.2. Link)

Fixed a semi-recent regression in the Plasma Wayland session that could cause the Baloo file indexer service to crash frequently (David Redondo, Frameworks 5.104. Link)

When getting new add-ons using the “Get New [Thing]” dialog, the sheet to let you choose which thing you want to get in case there’s more than one is now correctly scrollable in case it does not fit in the view (Ivan Tkachenko, Frameworks 5.104. Link)

Other bug-related information of interest:

Automation & Systematization

The tutorial for writing Kirigami apps has been rewritten for massively improved usefulness and helpfulness! (Thiago Sueto, Link)

The continuous integration systems for Gwenview and Kamoso now build the apps as Flatpaks for every change! (Neelaksh Singh, Link 1 and link 2)

Changes not in KDE that affect KDE

In the Plasma Wayland session, power management when using DisplayPort screens now works again for users of the Neon and Fedora KDE distros, which it turns out had not been building the KIdleTime library with its proper Wayland support enabled (Jonathan Riddell and Marc Deop i Argemí, right now! Link).

…Okay so technically Neon is in KDE, but it seemed more awkward to mention Neon separately elsewhere and Fedora KDE here, since both distros suffered from the same underlying issue that was causing the same user-facing bug, and both needed the same change to fix it.

…And everything else

This blog only covers the tip of the iceberg! If you’re hungry for more, check out https://planet.kde.org, where you can find more news from other KDE contributors.

How You Can Help

If you’re a user, upgrade to Plasma 5.27! If your distro doesn’t offer it and won’t anytime soon, consider switching to a different one that ships software closer to its developer’s schedules.

If you’re a developer, consider working on known Plasma 5.27 regressions! You might also want to check out our 15-Minute Bug Initiative. Working on these issues makes a big difference quickly!

Otherwise, visit https://community.kde.org/Get_Involved to discover other ways to be part of a project that really matters. Each contributor makes a huge difference in KDE; you are not a number or a cog in a machine! You don’t have to already be a programmer, either. I wasn’t when I got started. Try it, you’ll like it! We don’t bite!

And finally, KDE can’t work without financial support, so consider making a donation today! This stuff ain’t cheap and KDE e.V. has ambitious hiring goals. We can’t meet them without your generous donations!

Categories: FLOSS Project Planets

GNU Health: Fundación La Vicuña joins GNU Health

GNU Planet! - Fri, 2023-02-24 20:45

On Thursday, Feb 23rd, 2023, GNU Solidario and the Spanish NGO Fundación La Vicuña ORL have signed a cooperation agreement to promote and implement the Health and Hospital Management component from GNUHealth in those areas and institutions where Fundación La Vicuña has activities, mainly Spain and countries in Africa.

Fundación La Vicuña is a non-profit organization founded 15 years ago by a group of physicians, mostly ear, nose and throat specialists in Cadiz, Spain.

GNU Solidario and Fundacion La Vicuña share the goal of improving the lives of the underprivileged, through Social Medicine and universal access to healthcare. GNU Health will be a very valuable tool to assess the socioeconomic determinants of health and to minimize the impact in the vulnerable population, both in Spain and in the African continent. GNU Health will improve the management of health institutions and the daily medical practice where Fundación La Vicuña has missions. Patient evaluations, medical records, prescriptions, laboratory, surgeries and inpatient/hospitalization will be some of the areas that will benefit from GNU Health HMIS.

Casimiro García, president and founder of Fundación La Vicuña and Luis Falcón, founder and president of GNU Solidario, formalized the cooperation agreement this Thursday. In the coming weeks, GNU Solidario will train the team from Fnd. La Vicuña in the use of GNUHealth, and a development environment will be rolled out.

We are thrilled and looking forward to working hand in hand with Fundación la Vicuña, to put into practice the philosophy of open science and Libre software in healthcare for the betterment of our societies, delivering Social Medicine and dignity to those who need it most.

For more information you can visit Fundación la Vicuña homepage (in Spanish): http://www.fundacionlavicuna.org/

Source: https://my.gnusolidario.org/2023/02/24/fundacion-la-vicuna-joins-gnu-health/

Categories: FLOSS Project Planets

Daniel Roy Greenfeld: Programming languages I've learned

Planet Python - Fri, 2023-02-24 18:45

Matt Harrison asked in a tweet what my programming history was, so here's a list of the programming languages I've learned.

AppleBasic (ancient history)

My first computer was an Apple ][+. I learned AppleBasic from a book that came with the computer. I wrote oodles of text-based games. The most popular was a Star Trek battle clone that was well-appreciated in 10th grade.

FoxPro (1997-2000)

I learned FoxPro at my first professional software development job. I liked FoxPro for DOS and still have a soft spot for CLI dbase-style languages. The same can't be said for Visual FoxPro for Windows, which never clicked for me.

JavaScript (1998+)

Originally I just copy/pasted scripts from sites and books. I struggled with it and the DOM until encountering JQuery in 2008 plus reading "JavaScript: The Good Parts" the same year. That helped and I learned to enjoy the language.

Perl (1999)

I spent about six months coding with Perl. I enjoyed it, especially the regular expressions that have served me so well over the years. The challenge was that in my self-teaching as a junior developer, I didn't think about maintainability. When I had to go back to maintain stuff I wrote I was lost, got frustrated, and left it behind. Probably not fair to Perl, but it is what it is.

ColdFusion (2000-2006)

This was popular in US Federal government circles. In a way, it was like a closed-source PHP, with lots of idiosyncrasies. The biggest problem the language had was people - for whatever reason it attracted those who coded via cargo cult copy/paste programming and generally bad software design who refused to change or adapt. Which sucked because coming in to maintain someone else's code was a nightmare. Still, I have a soft spot for ColdFusion because it helped me identify that I preferred more dynamic languages over static ones.

VBScript (2000-2001)

This was one of Microsoft's abortive attempts to hijack JavaScript. I liked it more than the JavaScript of the time, but as it only worked on Internet Explorer that limited its usefulness.

Java (2000-2006)

Java during the time I used it was designed to be for the "Enterprise". Which meant tons of boilerplate code, lots of XML, and a general lack of fun. The heavyweight of Enterprise Java was a huge turnoff. I struggled with it so much that I developed an intolerance for strongly typed languages (from which I've only recovered in the last few years). I admit my opinion of Java is biased, I'm sure it would be awesome if I dug into the modern version.

Python (2005+)

This is the programming language and community that changed my life. Python fits into my brain and it's my go-to language for all kinds of scripts.

Lua (2011-2012)

For a brief time, I did Lua and enjoyed it. If I were into game scripting I'd probably still be using it.

Modern NodeJS (2018+)

In 2018 I finally knuckled down and learned the ways of NodeJS. Much as I love Python, knowing NodeJS has been a game-changer for me. Arrow functions are fun and I wish Python had a decent analog.

C# (2020+)

In 2020 I started to play with the Unity game engine. C# clicked for me surprisingly fast and it was my favorite part of writing games. It's part of why I wonder if I should revisit Java since the languages are so similar.

Go (2020)

I did some Golang in late 2020. I liked it and saw the virtues, especially the concurrency model. I just don't have any use cases for it that my other tools don't solve.

JSX (2021+)

To build out a website for work I learned the fundamentals ReactJS and JSX over a weekend. This blog is my first project, which I continue to extend and modify. I like noodling with JSX, and I can see why it has become so popular. While arguably not a programming language, it's clear it is a huge productivity boost for me and others. It's fun to write and that's what counts.

TypeScript (2022+)

Kicking and screaming I've been dragged into the TypeScript world. I know professional FE devs love it, but I'm more partial to NodeJS because I feel like I'm coding, not playing with types. That said, it is kind of relaxing figuring out the types. Where I think TypeScript fails is I haven't seen any dominant libraries built around its typing features. For example, in Python we have pydantic and FastAPI, which are powered by type annotations. I haven't seen anything like that for TypeScript. If you know of anything like it, point me to it!

Rust (2022+)

In December of 2022, I started to learn Rust. Its use in WASM is fascinating, as is the performance boost and the sophistication of the compiler. If only I had a business reason to practice it, but for now it's just a hobby tool.

Categories: FLOSS Project Planets

Dirk Eddelbuettel: ttdo 0.0.9 on CRAN: Small Update

Planet Debian - Fri, 2023-02-24 17:33

A new minor release of our ttdo package arrived on CRAN a few days ago. The ttdo package extends the excellent (and very minimal / zero depends) unit testing package tinytest by Mark van der Loo with the very clever and well-done diffobj package by Brodie Gaslam to give us test results with visual diffs (as shown in the screenshot below) which seemingly is so compelling an idea that it eventually got copied by another package which shall remain unnamed…

This release adds a versioned dependency on the just released tinytest version 1.4.1. As we extend tinytest (for use in the autograder we deploy within the lovely PrairieLearn framework) by consuming the tinytest code we have to update in sync.

There were no other code changes in the package beside the usual maintenance of badges and continuous integration setup.

As usual, the NEWS entry follows.

Changes in ttdo version 0.0.9 (2023-02-21)
  • Minor cleanup in README.md

  • Minor continuous integration update

  • Updated (versioned) depends on tinytest to 1.4.1

My CRANberries provides the usual summary of changes to the previous version. Please use the GitHub repo and its issues for any questions.

If you like this or other open-source work I do, you can now sponsor me at GitHub.

This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.

Categories: FLOSS Project Planets

GNU Health: Fundación La Vicuña joins GNU Health

GNU Planet! - Fri, 2023-02-24 13:54

On Thursday, Feb 23rd, 2023, GNU Solidario and the Spanish NGO Fundación La Vicuña ORL have signed a cooperation agreement to promote and implement the Health and Hospital Management component from GNUHealth in those areas and institutions where Fundación La Vicuña has activities, mainly Spain and countries in Africa.

Fundación La Vicuña is a non-profit organization founded 15 years ago by a group of physicians, mostly ear, nose and throat specialists in Cadiz, Spain.

GNU Solidario and Fundacion La Vicuña share the goal of improving the lives of the underprivileged, through Social Medicine and universal access to healthcare. GNU Health will be a very valuable tool to assess the socioeconomic determinants of health and to minimize the impact in the vulnerable population, both in Spain and in the African continent. GNU Health will improve the management of health institutions and the daily medical practice where Fundación La Vicuña has missions. Patient evaluations, medical records, prescriptions, laboratory, surgeries and inpatient/hospitalization will be some of the areas that will benefit from GNU Health HMIS.

Casimiro García, president and founder of Fundación La Vicuña and Luis Falcón, founder and president of GNU Solidario, formalized the cooperation agreement this Thursday. In the coming weeks, GNU Solidario will train the team from Fnd. La Vicuña in the use of GNUHealth, and a development environment will be rolled out.

We are thrilled and looking forward to working hand in hand with Fundación la Vicuña, to put into practice the philosophy of open science and Libre software in healthcare for the betterment of our societies, delivering Social Medicine and dignity to those who need it most.

For more information you can visit Fundación la Vicuña homepage (in Spanish): http://www.fundacionlavicuna.org/

Categories: FLOSS Project Planets

PyBites: How To Start Finishing – Learning from Agile Practices

Planet Python - Fri, 2023-02-24 13:00
Summary

Many of the agile tools, principles and guidelines used by large IT enterprises can be used by small teams or individual engineers to improve efficiency and create more value.

In this article, I’d like to explore these concepts with you to help you level up your engineering practice.

The underlying agile principle I’ll explore is “Stop Starting. Start Finishing.” In other words, rather than constantly starting new work, concentrate on completing the work you are currently doing-transforming from a Starter to a Finisher.

When Starters think of a new idea, they drop what they are doing and start working on it while it’s fresh in their minds. Inevitably this leaves them with a trail of unfinished projects. Whereas Finishers complete the project they are working on before choosing their next project.

And this doesn’t just apply to building apps. If you learn to be a Finisher, you can apply this principle to all those To-Do tasks cluttering your mind.

Starter or Finisher?

Like most psychological traits, a Finisher mindset isn’t binary – it’s a continuum and it’s situational. But we all generally trend towards Starter or Finisher. Which are you?

To find out which way you trend, crack open your favorite editor and create two headings:

  • Work I Started
  • Work I Completed

Work I Started

Think back over the last 7 days. Jot down all the work you started. Take a few minutes to do this and be generous with your definition of work. It should include all the little chores you started.

Did you wash the car? Take the dog for a walk? File your taxes? Celebrate the sheer variety of all you do!

When you are finished with this list, congratulate yourself. You acted like a Finisher and completed a task.

Work I Completed

Now write down the work you fully completed. Be honest. Completed means fully completed to the standard you set when you set out to do it.

Results

Now for some simple data analysis. Count the number of tasks you started and the number you finished. Did you finish more than 80% of the tasks you started? If so – and this was a typical 7 day stretch for you – move right along! You are already a Finisher and you don’t need this article.

Still reading? Me too! Don’t beat yourself up. You are where almost all of us are. You tend towards being a Starter. But with a little change in attitude and by adopting a few tools you can become more of a Finisher.

By the way, if you looked at your lists and thought, “I could write simple Python app to analyze this data much more efficiently”, opened an IDE and started coding away, you have a brilliant engineering mindset, but you are not winning any contests for being a Finisher!

Are we wired like this?

The tendency to be distracted is rooted in the traits that kept us alive in ancient caves and jungles. A mind that focusses on a single thing and ignores new stimulus is not well suited to an environment where new opportunities like food sources or challenges like predators emerge constantly and unexpectedly.

When something new appears, we are hard-wired to drop what we are doing and concentrate on the new. But we can consciously overcome these instincts.

You too can be a finisher

Like most of you, I am a natural Starter, not a Finisher. As a scrum-master in engineering, I knew I had to change that. My journey involved adopting some brilliant ideas and awesome tools borrowed from agile ways of working that have proven themselves time and again.

Organize Your Work Backlog (A better To-Do list)

The first engineering principle we can draw on will help us organize our work. Replace that nebulous, ever shifting To-Do list with a backlog. This is the way most agile teams organize their work to get the most out of limited resources.

A backlog is simply a list of tasks you want to do some time in the future. It can be housed on a notepad, a whiteboard or as physical cards in a pile, or it can be kept in a digital tool. I installed Trello on my phone. I use it because it goes wherever I go.

It’s the guidelines you set for yourself in managing your backlog that make it work. Backlog guidelines evolve to suit you but here are my ground rules as a starting point-

  • When you get a new task, add it to the backlog. The initial entry can be brief (you don’t want to interrupt what you are doing) and it should describe the task just enough so you will understand it later.
  • Organize your backlog regularly-on a fixed schedule if possible. If you can set aside time daily to do this, it helps. In agile we call this refinement and it includes:
    • Fill in the tasks’ details so you always know what you wanted to do and why.
    • Prune your backlog. Get rid of stale tasks that you will never get round to.
    • Right size the tasks. Tasks that can be done in less than an hour are less daunting and more likely to get done.
    • Reorder the tasks by priority. Are any of them time sensitive? Some are almost certainly more important than others. While you do this, you may find some aren’t important at all and you can delete them.

This does take a little work (less than it sounds), but once you have a backlog that you frequently refine you will have solved those issues with your unorganized To-Do list, and you have the first step of a workflow – which we’ll discuss now.

Workflow

Now we have a backlog, how does all the work get done?

Tasks move out of the backlog through one or more states until they end up in a column called Done.

While a workflow can be as elaborate as you like, I suggest starting with a very simple workflow. I have 3 states work can be in.

  • Backlog: (I hope you know what this is now. You can call it To Do if that helps)
  • In Progress: No longer in your backlog. You are working on it.
  • Done: The state all tasks aspire to. Your job is to help them get there!

The workflow works because of a few more guidelines:

  • New tasks are only added to the backlog. Try not to start work that isn’t in the backlog because the backlog is your refined, prioritized list. If you do need to add an emergency task, you can put it into In Progress but try to limit that. If you keep adding work In Progress you are probably still being a Starter.
  • Try to take work from the top of the backlog first since you agreed with yourself that this is your most important work.
  • Limit how many tasks are In Progress to a definite number (3 is the number that works for me). This is covered in the Limit Work In Progress (WIP) section below.
  • Only work on the task as it is described. Ideas tend to grow more elaborate and complex if you let them. Don’t let that happen. If you think of improvements as you work on a task, add these improvements as new backlog items-don’t do them now.
  • Don’t obsess. If something will only take 5 minutes, you don’t need a card.
  • If you need to break one of these guidelines every so often, don’t sweat it. Even if ‘run away from the escaped lion’ isn’t an In Progress card, you should probably do it anyway. If you are constantly breaking the guidelines, think about why that is and work out how to fix it.
Limiting Work In Progress (WIP)

If there is one takeaway from this post that is the most likely to help you become a ‘Finisher’ it’s this one. Limit Work In Progress (WIP).

Starters like us do too much at once. We just have so much going on that we feel we have to make progress on multiple fronts at once. But more-at-once kills productivity and Finishing.

If we tackle too many tasks we have to frequently context switch, incurring ‘startup costs’. This cost of switching tasks is real and proven. We pay for distractions, and we pay for trying to work on 5 things at once.

The engineering principle we can use to counteract the ‘too many things at once’ principle is limiting our Work In Progress (WIP) – a contract we make with ourselves. We choose a WIP limit and under normal circumstances we stick to it. This limit is the number of tasks we allow to be In Progress at once. This is so central to the way agile teams build software some of the work management tools like Jira allow you to set a WIP limit on each workflow column. If the team exceeds this number, the column goes scary red.

Just to be clear, a WIP of 3 does NOT mean I can work on an article, a Bite exercise and a project for my portfolio all at the same time, using 3 computers. I still only work on 1 task at once. The WIP is the number of tasks I have on my current list of tasks in progress. If I get stuck on one, I can switch to another.

NOTE: A WIP limit is a maximum but we don’t need to fill the maximum. Try to limit your actual number of tasks in progress to 1 even if you set a higher WIP limit. When you move a task to Done (look at you –being a Finisher) before you automatically move a task to In Progress from the backlog and start work, is there a task already In Progress you can finish first?

Other useful tools and techniques

Now, since the tasks we are working on are right sized and small (thank you, backlog refinement) we can use a couple of tools to help us focus and work on them to completion (thus becoming a Finisher).

My favorites are Pomodoro and micro-habits. Let’s see how they work together!

Pomodoro

Pomodoro focuses your attention on one In Progress task at a time. Coupled with backlog Management and your WIP limit, it is a powerful productivity tool.  It consists of these steps:

  1. Decide on the task to be done (using the tools and techniques you now know about).
  2. Set the pomodoro timer (typically for 25 minutes, related Pybites tool).
  3. Work on the task. The discipline here is to focus on that single task. Avoid distractions. You may decide to turn off social media notifications and you could choose a work area without distractions.
  4. End work when the timer rings and take a short break (typically 5–10 minutes). You may want to ‘just finish this task’ and postpone the break knowing you are only 5 minutes away from completion. But try to avoid that mindset. You are often not as near to done as you think, and there is solid science behind the cycle of work and breaks and the length of each.
  5. If you have finished fewer than three pomodoros, go back to Step 2 and repeat until you go through all three pomodoros.
  6. After three pomodoros are done, take the fourth pomodoro and then take a long break (typically 20 to 30 minutes). Once the long break is finished, return to step 2.

Since many software engineers have embraced Pomodoro and love to write fun and useful software, there are many online Pomodoro timers you can install / run online for free. You could even create your own.

What? Build it right now? NO! Break it down into tasks in your Backlog 

Micro Habits

Another concept to help you be a Finisher is that of micro habits. These train us to make our habits (which I relate to tasks) achievable in a short time. We will really accelerate our journey to Finishing by breaking tasks into small chunks – something we are likely to achieve in a single Pomodoro session. Micro habits become a self-fulfilling prophecy. We Finish frequently, so we expect to Finish, and this propels us to Finish more. Also, with smaller tasks we have less inertia to overcome when we think about starting a new one.

As a concrete example, let’s go back to those Pomodoro tracker programs we love to build. Could you write the entire tracker as a single Backlog item, move it to In Progress and finish it in a single Pomodoro session? I know I couldn’t. Using the micro habit principle, break this daunting task into smaller chunks, each of which you could likely achieve in a single session. Maybe the first task is to research and learn what a Pomodoro timer is? Or write code that just runs for 25 minutes and alerts you in some way? I think I could knock out a Python script that sleeps for 25 minutes and writes a line to output in a single Pomodoro session, so why don’t I define that as my first task and be a Finisher?

Minimum Viable Product (MVP)

The Minimum Viable Product (MVP) is another engineering principle that we can use to finish more work. The concept of an MVP is to build the absolute minimum product to satisfy your requirements. You can improve on it in later tasks. This mindset keeps you from adding scope to the work you are doing until it becomes a never-ending task, and each task you finish lets you get feedback on the next improvement.

As an example, if I want to create a means of getting from my home to a park, instead of working on a  helicopter rotor blade, could I start with the task of buying a bus pass? On the first rainy day where the bus is late, I will have feedback what to do next. Buy an umbrella? I may end up with that helicopter, but I will incrementally improve my experience in a way that 10 years of construction in my garage will not.

By the way, many of us in the software delivery world now refer to the Minimum Lovable Product (MLP) as an evolution from MVPThere are many MLP’s in production!

Inspect And Adapt

Another essential agile principle is Inspect and Adapt. Frequently look at WHAT you produced and HOW you produced it to see if you can make small improvements in the way you work that build over time.

Are you Finishing more? Learn from the work you didn’t finish. Be honest with what went wrong. Was the task small enough? Did you let it grow larger as you worked on? Were you distracted or did you start to do other work?

As you look into the reasons you were temporarily a Starter, not a Finisher, please be gentle on yourself. Yes, you want to learn what went awry so you can course correct, but this is not an opportunity to beat yourself up. You wouldn’t have stumbled if you hadn’t tried to walk.

Accountability partners / circles

Let’s face it. We stay more disciplined when we have to discuss our progress with a friend or group. Accountability works well if you regularly report on what you intend to do in the next 7 days and then discuss whether you accomplished that goal a week later. Please remember – you and your accountability partners should be cheerleaders for each other. Yay! I found an accountability partner on the Pybites slack channel. It’s a great place to start.

Related Pybites podcast episode.

Celebrate the wins

As you start to finish more, it’s important we celebrate those wins. Treat yourself for your successes. Try to make this a regular part of your relationship with your accountability partner or circle. If you celebrate winning and allow yourself to fail without consequence, you will create a virtuous circle where success leads to more success.

Related Pybites article.

Conclusion

As humans, we are alike in many respects. We are hard wired to concentrate on new shiny objects because they could be new food sources or dangers.

Translating this to the modern world, even when we fully committed to completing a task, we are likely to think of several other ideas that seem important enough to supersede what we are currently working on. But this context switching is stressful and inefficient. It’s better to Finish what we Started first, then decide what to work on next.

We explored this subtle attitude shift along with a few tried-and-tested agile tools and techniques to improve the amount of work we Finish.

On a personal note, I thought of the idea for this article a while back and created the outline. Before I finished writing it, I started a couple of fun new projects and the article lay here on my PC, unfinished. Undelivered. Wasted.

So I added this article to my backlog, concentrated on finishing my In Progress tasks and when the time was right (today) I committed to completing the article. I stayed focused and finished the initial draft.

Next, I will respond to feedback until it’s ready to publish. I just moved closer to being a Finisher, not a Starter. And you can too!

Categories: FLOSS Project Planets

Kubuntu 22.04.2 LTS Update Available

Planet KDE - Fri, 2023-02-24 11:30

The second point release update to Kubuntu 22.04 LTS (Jammy Jellyfish) is out now. This contains all the bug-fixes added to 22.04 since its first point release in August 2022. Users of 22.04 can run the normal update procedure to get these bug-fixes.

Kubuntu Manual 22.04.2 should be out next week

You can watch the progress here.

See the Ubuntu 22.04.2 LTS Release Announcement, the Ubuntu 22.04.2 Release Notes, and the Kubuntu Release Notes.

Download all available released images.

Categories: FLOSS Project Planets

VxWorks for Qt 5.15.12 Released

Planet KDE - Fri, 2023-02-24 10:24

The Qt Company is expanding the number of supported releases for VxWorks with the latest Qt 5.15.12 Long Term Support (LTS) version for commercial license holders. The release is a  source code release made on top of the Qt 5.15.12 LTS Commercial release. Further Qt releases with VxWorks support are also being planned.

Categories: FLOSS Project Planets

Snowstorms, Kittens and Shattered dreams

Planet KDE - Fri, 2023-02-24 09:12
Icy morning Witch Wells Az

Long ago I applied for my dream job at a company I have wanted to wok for since its beginning and I wasn’t ready technically. Fast forward to now, I am ready! A big thank you goes out to Blue Systems for that. So I go out and find the perfect role and start the application process. The process was months long, but was going very well, the interviews and I passed the technical with flying colors. I got to the end where the hiring lead told me he was submitting my offer… I was so excited, so much so, I told my husband and parents “I got the job!” I know, I jinxed myself there. Soon I receive the “There was a problem”.. One obscure assessment called GIA came back not so good. I remember that day, we were in the middle of a long series of winter storms and I when I took the test, my kitten decided right then it was me time. I couldn’t very well throw her out into the snowstorm, so I continued on the best I could. It is my fault, it clearly states to be distraction free. So I speak again to the hiring lead and we both feel with my experience and technical knowledge and abilities we can still move forward. I still had hope. After some time passes, I asked for an update and got the dreaded rejection. I am told it wasn’t just the GIA, but that I am not a good overall fit for the company. In one fell swoop my dreams are dashed and final, for this and all roles within that company. I wasn’t given a reason either. I am devastated, heart broken, and shocked. I get along with everyone, I exceed the technical requirements, and I work well in the community. Dream door closed.

I will not let this get me down. I am moving on. I will find my place where I ‘fit in’.

With that said, I no longer have the will, passion, or drive to work on snaps anymore. I will leave instructions with Jonathon as to what needs to be done to move forward. The good news is my core22 kde-neon extension was merged into upstream snapcraft, so whomever takes over will have a much easier time knocking them out. @kubuntu-council I will do whatever it takes to pay back the money for the hardware you provided me to do snaps, I am truly sorry about this.

What does my future hold? I will still continue with my Debian efforts. In fact, I have ventured out from the KDE umbrella and joined the go-team. I am finalizing my packaging for

https://github.com/charmbracelet/gum

and it’s dependencies: roff, mango, mango-kong. I had my first golang patch for a failing test and have submitted it upstream. I will upload these to experimental while the freeze is on.

I will be moving all the libraries in the mycroft team to the python umbrella as they are useful for other things and mycroft is no more.

During the holidays I was tinkering around with selenium UI testing and stumbled on some accessibility issues within KDE, so I think this is a good place for me to dive into for my KDE contributions.

I have been approached to collaborate with OpenOS on a few things, time permitting I will see what I can do there.

I have a possible gig to do some websites, while I move forward in my job hunt.

I will not give up! I will find my place where I ‘fit in’.

Meanwhile, I must ask for donations to get us by. Anything helps, thank you for your consideration.

https://gofund.me/a9c36b87

Categories: FLOSS Project Planets

Scarlett Gately Moore: Snowstorms, Kittens and Shattered dreams

Planet Debian - Fri, 2023-02-24 09:12
Icy morning Witch Wells Az

Long ago I applied for my dream job at a company I have wanted to wok for since its beginning and I wasn’t ready technically. Fast forward to now, I am ready! A big thank you goes out to Blue Systems for that. So I go out and find the perfect role and start the application process. The process was months long, but was going very well, the interviews and I passed the technical with flying colors. I got to the end where the hiring lead told me he was submitting my offer… I was so excited, so much so, I told my husband and parents “I got the job!” I know, I jinxed myself there. Soon I receive the “There was a problem”.. One obscure assessment called GIA came back not so good. I remember that day, we were in the middle of a long series of winter storms and I when I took the test, my kitten decided right then it was me time. I couldn’t very well throw her out into the snowstorm, so I continued on the best I could. It is my fault, it clearly states to be distraction free. So I speak again to the hiring lead and we both feel with my experience and technical knowledge and abilities we can still move forward. I still had hope. After some time passes, I asked for an update and got the dreaded rejection. I am told it wasn’t just the GIA, but that I am not a good overall fit for the company. In one fell swoop my dreams are dashed and final, for this and all roles within that company. I wasn’t given a reason either. I am devastated, heart broken, and shocked. I get along with everyone, I exceed the technical requirements, and I work well in the community. Dream door closed.

I will not let this get me down. I am moving on. I will find my place where I ‘fit in’.

With that said, I no longer have the will, passion, or drive to work on snaps anymore. I will leave instructions with Jonathon as to what needs to be done to move forward. The good news is my core22 kde-neon extension was merged into upstream snapcraft, so whomever takes over will have a much easier time knocking them out. @kubuntu-council I will do whatever it takes to pay back the money for the hardware you provided me to do snaps, I am truly sorry about this.

What does my future hold? I will still continue with my Debian efforts. In fact, I have ventured out from the KDE umbrella and joined the go-team. I am finalizing my packaging for

https://github.com/charmbracelet/gum

and it’s dependencies: roff, mango, mango-kong. I had my first golang patch for a failing test and have submitted it upstream. I will upload these to experimental while the freeze is on.

I will be moving all the libraries in the mycroft team to the python umbrella as they are useful for other things and mycroft is no more.

During the holidays I was tinkering around with selenium UI testing and stumbled on some accessibility issues within KDE, so I think this is a good place for me to dive into for my KDE contributions.

I have been approached to collaborate with OpenOS on a few things, time permitting I will see what I can do there.

I have a possible gig to do some websites, while I move forward in my job hunt.

I will not give up! I will find my place where I ‘fit in’.

Meanwhile, I must ask for donations to get us by. Anything helps, thank you for your consideration.

https://gofund.me/a9c36b87

Categories: FLOSS Project Planets

Python for Beginners: Convert XML to JSON in Python

Planet Python - Fri, 2023-02-24 09:00

We use different file formats to store and transmit data generated from software systems. Sometimes, we need to convert an XML file to JSON to communicate between two software. This article discusses how to convert an XML file or string into JSON format in Python.

Table of Contents
  1. What is XML?
  2. What is JSON File Format?
  3. XML String to JSON String in Python
  4. Convert XML String to JSON File in Python
  5. XML File to JSON String in Python
  6. Convert XML File to JSON File in Python
  7. Conclusion
What is XML?

XML stands for Extensible Markup Language. This is a standard markup language for describing and structuring data. XML was designed to store and transport data, and it is widely used in various applications and technologies, such as web services, database systems, document formats, and many others.

XML uses tags to define elements, attributes to define properties of those elements, and a hierarchical structure to organize the data. XML documents can be validated against a specific schema or Document Type Definition (DTD) to ensure their conformance to a specific standard.

For instance, the following is an XML string containing the details of an employee.

<?xml version="1.0"?> <employee> <name>John Doe</name> <age>35</age> <job> <title>Software Engineer</title> <department>IT</department> <years_of_experience>10</years_of_experience> </job> <address> <street>123 Main St.</street> <city>San Francisco</city> <state>CA</state> <zip>94102</zip> </address> </employee>

In the above XML string, <employee> is the root element. You can observe that each element in the string is represented using the following syntax.

<element_name> value </element_name>

XML is a platform-independent language. We can use it on any operating system and easily share it between different applications and systems. It is also human-readable and can be easily understood and edited by both machines and humans.

What is JSON File Format?

JSON stands for JavaScript Object Notation. It is a lightweight, text-based data interchange format that is easy for humans to read and write and easy for machines to parse and generate. Its structure resembles a python dictionary.

JSON is based on a subset of the JavaScript programming language, but it is language-independent and can be used with any programming language. It is often used as a data format for web APIs, as it is a common way to exchange data between the client and server.

JSON uses a simple syntax to represent data structures, such as objects and arrays. Data is represented using key-value pairs, where the keys are strings and the values can be of any JSON-supported data type, such as strings, numbers, objects, and arrays.

Following is the JSON representation of data shown in the previous XML string.

{ "employee": { "name": "John Doe", "age": 35, "job": { "title": "Software Engineer", "department": "IT", "years_of_experience": 10 }, "address": { "street": "123 Main St.", "city": "San Francisco", "state": "CA", "zip": 94102 } } }

JSON is more concise and easier to parse than XML, making it a popular choice for data transfer between applications and systems. It is also widely supported by modern programming languages, making it an ideal format for web-based applications.

To convert XML files and strings to JSON, we will use the xmltodict module and the json module.

XML String to JSON String in Python

To convert an XML string to a JSON string, we will first convert the XML string to a Python dictionary. For this, we will use the parse() method defined in the xmltodict module. The parse() method takes an XML string as its input argument and returns the corresponding dictionary.

Next, we will convert the python dictionary to a JSON string. For this, we will use the dumps() method defined in the json module. The dumps() method takes the python dictionary as its input argument and returns the corresponding JSON string after execution.

You can observe this in the following example.

import xmltodict import json xml_string="""<?xml version="1.0"?> <employee> <name>John Doe</name> <age>35</age> <job> <title>Software Engineer</title> <department>IT</department> <years_of_experience>10</years_of_experience> </job> <address> <street>123 Main St.</street> <city>San Francisco</city> <state>CA</state> <zip>94102</zip> </address> </employee>""" print("The XML string is:") print(xml_string) python_dict=xmltodict.parse(xml_string) json_string=json.dumps(python_dict) print("The JSON string is:") print(json_string)

Output:

The XML string is: <?xml version="1.0"?> <employee> <name>John Doe</name> <age>35</age> <job> <title>Software Engineer</title> <department>IT</department> <years_of_experience>10</years_of_experience> </job> <address> <street>123 Main St.</street> <city>San Francisco</city> <state>CA</state> <zip>94102</zip> </address> </employee> The JSON string is: {"employee": {"name": "John Doe", "age": "35", "job": {"title": "Software Engineer", "department": "IT", "years_of_experience": "10"}, "address": {"street": "123 Main St.", "city": "San Francisco", "state": "CA", "zip": "94102"}}} Convert XML String to JSON File in Python

Instead of converting it into a string, we can also convert an XML string to a JSON file. For this, we will use the following steps.

  • First, we will convert the XML string to a dictionary using the parse() method defined in the xmltodict module.
  • Then, we will open an empty JSON file in write mode using the open() function. The open() function takes the file name as its first input argument and the python literal “w” as its second argument. After execution, it returns a file pointer. 
  • Once we get the file pointer, we will save the python dictionary as JSON to the file using the dump() method defined in the json module. The dump() method takes the dictionary as its first argument and the file pointer as the second input argument. After execution, it saves the dictionary into the json file as a json object.
  • Finally, we will close the file using the close() method.

After executing the above steps, we can easily convert an XML string to a JSON file. You can observe this in the following example.

import xmltodict import json xml_string="""<?xml version="1.0"?> <employee> <name>John Doe</name> <age>35</age> <job> <title>Software Engineer</title> <department>IT</department> <years_of_experience>10</years_of_experience> </job> <address> <street>123 Main St.</street> <city>San Francisco</city> <state>CA</state> <zip>94102</zip> </address> </employee>""" python_dict=xmltodict.parse(xml_string) file=open("person.json","w") json.dump(python_dict,file) file.close()

The output file looks as follows.

JSON File XML File to JSON String in Python

To convert an XML file into a JSON string, we can use the dumps() method defined in the json module. For this, we will first open the XML file in read mode using the open() function. Then, we will read the contents of the XML file as a string using the read() method. 

We will use the following XML file to convert it into a JSON string.

XML File

Once we get the XML string, we will convert it to a python dictionary using the parse() method defined in the xmltodict module. Next, we will convert the dictionary into JSON string using the dumps() method defined in the json module. 

You can observe this in the following example.

import xmltodict import json xml_file=open("person.xml","r") xml_string=xml_file.read() python_dict=xmltodict.parse(xml_string) json_string=json.dumps(python_dict) print("The JSON string is:") print(json_string)

Output:

The JSON string is: {"employee": {"name": "John Doe", "age": "35", "job": {"title": "Software Engineer", "department": "IT", "years_of_experience": "10"}, "address": {"street": "123 Main St.", "city": "San Francisco", "state": "CA", "zip": "94102"}}} Convert XML File to JSON File in Python

We can also convert an XML file to a JSON file in python. For this, we will use the following steps.

  • First, we will open the XML file in read mode using the open() function.
  • Next, we will read the contents of the XML file as a string using the read() function. 
  • Then, we will convert the XML string to a python dictionary using the parse() method defined in the xmltodict module.
  • Now that we have the XML file as a dictionary, we will open an empty JSON file in write mode using the open() function. 
  • Next, we will dump the dictionary into the json file using the dump() method defined in the JSON module. The dump() method takes the dictionary as its first argument and the file pointer as the second input argument. After execution, it saves the dictionary into the json file as a json object.
  • Finally, we will close the files using the close() method.

After execution of the above steps, the data in the XML file will be saved in the JSON file. You can observe this by executing the following code.

import xmltodict import json xml_file=open("person.xml","r") xml_string=xml_file.read() python_dict=xmltodict.parse(xml_string) file=open("person.json","w") json.dump(python_dict,file) file.close()

After execution of the above code, the XML data from “person.xml” will be saved into “person.json” in JSON format.

Conclusion

In this article, we have discussed ways to convert an XML string or file into JSON format in Python. To learn more about file conversions, you can read this article on how to convert JSON to XML in python. You might also like this article on how to convert YAML to XML in Python.

I hope you enjoyed reading this article. Stay tuned for more informative articles.

Happy Learning!

The post Convert XML to JSON in Python appeared first on PythonForBeginners.com.

Categories: FLOSS Project Planets

Golems GABB: What is Predictive Marketing?

Planet Drupal - Fri, 2023-02-24 08:24
What is Predictive Marketing? Editor Fri, 02/24/2023 - 16:41

Predictive marketing is a type of marketing that uses a large amount of information to predict customer behavior and needs accurately. It involves the analysis of all data to determine the best and most effective version of the marketing strategy. 
Based on a client's past shopping experience, marketers develop marketing strategies. Therefore, you can create more effective personalized ads in the future that will increase conversions. By forecasting correctly, you can also reduce customer churn and increase demand for your products or services. Stand out from the competition and stay ahead of the game by doing this.
Many famous companies have used predictive modeling in marketing for years because they have seen effective results. When analytics are adequately conducted, websites can increase their customers and orders. A business owner who has mastered predictive marketing can anticipate their target audience's needs and keep up with all current trends.

Categories: FLOSS Project Planets

Axelerant Blog: Why Axelerant Invests In Leadership Training For All

Planet Drupal - Fri, 2023-02-24 07:29
Introduction

This article enumerates why an organization must invest in leadership training programs for budding and existing leaders.

Categories: FLOSS Project Planets

PyBites: Finding value and purpose in your work

Planet Python - Fri, 2023-02-24 07:19

Watch here:

Or listen here:

Welcome back to the Pybites podcast! This week we have an inspirational talk with our special guest Cassandra Babilya! We talk about the importance of finding value and purpose in your work.

We talk about:

– Considering your life purpose.

– Your professional values and your personal values.

– How do you identify that something is wrong at work.

We discuss the effects that being disengaged with your work can have on your physical and mental well-being. The key point being to really pay attention to you “bio-feedback”:

– Are you exhausted all the time?

– Are you getting sick more often?

– Is your mental health suffering?

To get started on analysing your situation and making those first steps toward change, we ask you four questions (grab a pen and paper!):

1. Do you feel a disconnect between your personal values and your professional values?

2. The last time you jumped out of bed excited for the day, what were you going to do that day?

3. What do people often come to you for help with?

4. What’s missing when you’re not in the room?

Start small; identify where you are today and identify one thing that you can do today that will bring you closer to where you want to be.

Connect with Cassandra:
– LinkedIn
– Website
– Instagram
– Newsletter

Categories: FLOSS Project Planets

Pages