Skip to main content

Some python useful methods

Project description

Introduction

This package provides python useful methods.

It relates to following kinds of operations:

  1. System level operations (system.py)

It provides helper methods to:

  • read and write files,

  • read directories,

  • execute commands,

  • store and load list and dict,

  • trace printing,

  • creating temporary files,

  • etc.

  1. Various python helpers (utils.py)

About:

  • ordereddict and dict manipulations

  • list manipulations

  • duration recording

  1. BeautifulSoup methods (bs.py)

  • remove elements

  • remove attributes

  • remove comments

  • replace entire strings

  • unwrap tags

  1. Postgres level operations (postgres.py). It requires psycopg2 egg !

It provides helper methods to:

  • single or multiple select,

  • insert, update, delete rows,

  • etc.

Tests

Can be run with: bin/python -m unittest discover

Changelog

0.28 (2023-03-29)

  • Added utils.one_of_dict_values that gives the first non empty value of a list of keys. [sgeulette]

  • Added utils.all_of_dict_values that returns a not empty values list from a dict following a keys list [sgeulette]

0.27 (2023-02-27)

  • Added utils.sort_by_indexes that will sort a list of values depending on a list of indexes. [gbastien]

0.26 (2022-12-12)

  • Added stop to print error and exit. [sgeulette]

0.25 (2022-09-16)

  • Added get_git_tag. [sgeulette]

0.24 (2022-08-19)

  • Added utils.time_start and utils.time_elapsed to print elapsed time from start. Intended to be easily used when debugging… [sgeulette]

0.23 (2022-07-01)

  • Added utils.append to append a value and return it. [sgeulette]

0.22 (2022-04-28)

  • Added utils.get_clusters to display a list of number grouped by clusters. [gbastien]

0.21 (2022-04-26)

  • Added utils.merge_dicts to be able to merge several dicts for which values are list, list are extended in final result. [gbastien]

0.20 (2022-02-10)

  • Modified memory to return more useful information. [sgeulette]

0.19 (2022-01-21)

  • Added process_memory to return current process memory. [sgeulette]

  • Added memory to return RAM information. [sgeulette]

0.18 (2022-01-12)

  • Made insert_in_ordereddict python3 compatible. [sgeulette]

  • Added odict_pos_key to get key at position in ordereddict. [sgeulette]

0.17 (2022-01-04)

  • Added timed and ftimed functions. [sgeulette]

  • Added OrderedDict for load_var function [sgeulette]

0.16 (2021-10-27)

  • Added iterable_as_list_of_list function. [sgeulette]

  • Added date in runCommand output [sgeulette]

0.15 (2021-04-27)

  • Added ln_key parameter in read_dictcsv method. [sgeulette]

0.14 (2021-04-21)

  • Added read_dictcsv function. [sgeulette]

  • Added utils.replace_in_list function to ease replacement of values in a list. [gbastien]

  • Added safe_encode function. [sgeulette]

0.13 (2020-10-07)

  • Added insert_in_ordereddict function to easier insert a new key at needed position. [sgeulette]

0.12 (2020-05-19)

  • Update syntax for py 3. [odelaere]

0.11 (2018-10-12)

  • Added warning log level function [odelaere]

0.10 (2018-07-23)

  • Added to_skip parameter in read_dir functions. [sgeulette]

0.9 (2017-07-28)

  • Added read_csv function. [sgeulette]

0.8 (2017-07-19)

  • runCommand can append to file. [sgeulette]

0.7 (2017-06-26)

  • Just release on pypi for collective.documentgenerator. [sgeulette]

0.6 (2017-02-08)

  • runCommand: return as third value the return code of the command. [sgeulette]

0.5 (2017-02-08)

  • Added outfile parameter to runCommand. [sgeulette]

0.4 (2016-12-07)

  • Added param to get only files in dir. [sgeulette]

  • Added methods for bs4 (beautifulsoup) [sgeulette]

0.3 (2016-09-21)

  • Return empty list when file doesn’t exist. [sgeulette]

0.2 (2016-04-15)

  • Added options on read_file. [sgeulette]

0.1 (2015-06-03)

  • Initial release. [sgeulette]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imio.pyutils-0.28.tar.gz (11.9 kB view details)

Uploaded Source

File details

Details for the file imio.pyutils-0.28.tar.gz.

File metadata

  • Download URL: imio.pyutils-0.28.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.6

File hashes

Hashes for imio.pyutils-0.28.tar.gz
Algorithm Hash digest
SHA256 c123a5072d8d70d47914d92aed0a60501de3fe0f442074e8abbc28fbbea525ec
MD5 6429a6b4e0de5aa84ba3db71e2128ff9
BLAKE2b-256 d36e9bca1887c3fa179ea529ff20b7359492677d1c4f6f00093b09d66c7e3c5e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page