Saravanan666/pypi-org huggingface dataset:
Package: pgtest
pgtestCreates a temporary, local PostgreSQL database cluster and server specifically for unittesting, and cleans up after itself.PGTest(username='postgres', port=None, log_file=None, no_cleanup=False,
       copy_cluster=None, base_dir=None, pg_ctl=None, max_connections=5)

Args:
    username - str, username for default database superuser
    port - int, port to connect on; you must ensure that the port is unused
    log_file - str, path to place the log file
    no_cleanup - bool, don't clean up dirs after PGTest.close() is called
    copy_cluster - str, copies cluster from this path
    base_dir - str, path to the base directory to init the cluster
    pg_ctl - str, path to the pg_ctl executable to use
    max_connections - int, maximum number of connections to the cluster

Attributes:
    PGTest.port - int, port number bound by PGTest
    PGTest.cluster - str, cluster directory generated by PGTest
    PGTest.username - str, username used by PGTest. Default is 'postgres'
    PGTest.log_file - str, path to postgres log file
    PGTest.pg_ctl - str, path to pg_ctl executable
    PGTest.url - str, url for default postgres database on the cluster
    PGTest.dsn - dict, dictionary containing dsn key-value pairs for the
                 default postgres database on the cluster
Methods:
    close() - Closes this instance of PGTest, cleans up directoriesUsage as an instance>>> from pgtest.pgtest import PGTest
>>> import psycopg2
>>> pg = PGTest()
Server started: postgresql://postgres@localhost:47251/postgres
>>> pg.port
47251
>>> pg.cluster
'/tmp/tmpiDtBjs/data'
>>> pg.username
'postgres'
>>> pg.log_file
'/tmp/tmpiDtBjs/pgtest_log.txt'
>>> pg.pg_ctl
u'/usr/lib/postgresql/9.4/bin/pg_ctl'
>>> pg.url
'postgresql://postgres@localhost:47251/postgres'
>>> pg.dsn
{'user': 'postgres', 'host': 'localhost',
'port': 47251, 'database': 'postgres'}
>>> # Connect with other db driver here, e.g. psql, psycopg2,
>>> # sqlalchemy etc
>>> psycopg2.connect(**pg.dsn)
>>> pg.close()
Server stoppedOr use as a context:>>> from pgtest.pgtest import PGTest
>>> import psycopg2
>>> with PGTest() as pg:
...    # connect to db with psycopg/sqlalchemy etc
...    psycopg2.connect(**pg.dsn)
...    # Do other database actions here
>>> # When the context exits, the db cluster and service is deleted unless specifiedUse withunittestin thesetUp()andtearDown()methods:import unittest
from pgtest.pgtest import PGTest

class TestThirdPartyDrivers(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.pg = pgtest.PGTest()
        cls.base_dir = cls.pg._base_dir

    @classmethod
    def tearDownClass(cls):
        cls.pg.close()

    def test_something(self):
        self.assertTrue(isinstance(self.pg, PGTest)
Package: pgtestdbpy
pgtestdbpyPython clone ofpgtestdb.pipinstallpgtestdbpyIn summary, it's a couple of helper functions that allow you to quickly clone Postgres databases that you've applied migrations to. In a small number of milliseconds, each test (including tests running in parallel) gets a fresh db with empty tables, all the sequences reset, etc.In developing this on my mac, for reasons I don't quite understand, running with Postgres in docker (viacolima) was substantially quicker that running Postgres natively. So I agree with Peter's advice, just copythis fileanddocker compose up -d db.There are two context managers that can be used in conjunction or independently depending on test setup:pgtestdbpy.templates(config, migrators):Creates a new user and database for a migrator.Runs the set of migrations.Marks the database as aTEMPLATE DATABASEso that it can be cheaply cloned.Yields.Drops the template database and the user.pgtestdbpy.clone(config, migrator):Does aCREATE DATABASE WITH TEMPLATE(from a template database made above) giving it a unique random name.Yields a Postgres url for it.Drops the database.Exampleconftest.pyusage below, in theory (I haven't tested this) it should be easy to run tests in parallel using theconnfixture - each with a separate database instance - andpytest-xdistor equivalent. In this example we justfromtypingimportIteratorimportpgtestdbpyimportpsycopgimportpytestdefmigrate(url:str)->None:withpsycopg.connect(url)asconn:conn.execute("CREATE TABLE foo (a INT)")migrator=pgtestdbpy.Migrator(migrate)config=pgtestdbpy.Config()@pytest.fixture(scope="session")defdb()->Iterator[None]:withpgtestdbpy.templates(config,migrator):yield@pytest.fixture()defconn(db)->Iterator[pgtestdbpy.PsycoConn]:withpgtestdbpy.clone(config,migrator)asurl:withpsycopg.connect(url)as_conn:yield_conn
Package: pgtg
ProgGrid Traffic Gym (pgtg)A driving simulation on a grid with procedural generated maps and traffic. Compatible with the Gymnasium API standard.InstallationpipinstallpgtgUsageThe easiest way to use pgtg is to create the environment with gymnasium:importpgtgenv=gymnasium.make("pgtg-v0")The package relies onimportside-effects to register the environment
name so, even though the package is never explicitly used, its import is
necessary to access the environment.If you want to access the environment constructor directly this is also possible:frompgtgimportPGTGEnvenv=PGTGEnv()EnvironmentProgGrid Traffic Gym procedurally generates a map consisting of multiple preconstructed tiles or loads a map from a file. The goal is to drive from the start of the map to the end. The navigation task is not part of this environment, instead a shortest path is provided and marked on the map.The environment is highly customizable, see the constructor documentation for more info.Action SpaceProgGrid Traffic Gym has aDiscrete(9)action space.ValueMeaning0accelerate left and up1accelerate left2accelerate left and down3accelerate up4don't accelerate5accelerate down6accelerate right and up7accelerate right8accelerate right and downObservation SpaceProgGrid Traffic Gym has aDictobservation space that shows the 9x9 area the agent currently is inside.KeyTypeExplanation"position"MultiDiscreteThe x and y position of the agent within the observation window."velocity"BoxThe velocity of the agent is x and y direction."map"DictThe 9x9 are of the map the agent is currently inside. The keys are the name of the features ("walls","goals","ice","broken road","sand", and"traffic"). Each item is aMultiBinarythat encodes that feature as a hot one encoding.Most reinforcement learning implementations can't deal withDictobservations, thus it might be necessary to flatten the observations. This is easily doable with thegymnasium.wrappers.FlattenObservationwrapper:fromgymnasium.wrappersimportFlattenObservationenv=FlattenObservation(env)RewardCrossing a subgoal is rewarded with+100 / number of subgoalsas is finishing the whole map. Moving into a wall or traffic is punished with-100and ends the episode. Standing still or moving to a already visited position can also penalized but is not per default. The reward values for each of this can be customized.Render modesNameExplanationhumanrender()returnsNonebut a pygame window showing the environment is opened automatically whenstep()is called.rgb_arrayrender()returns anp.arrayrepresenting a image.pil_imagerender()returns aPIL.Image.Image, useful for displaying inside jupiter notebooks.ObstaclesNameEffectIceWhen driving over a square with ice, there is a chance the agent moves in a random direction instead of the expected one.SandWhen driving over sand the agent is slowed, as the velocity is reset to 0 every step.Broken roadWhen driving over broken road, there is a chance for the agent to get a flat tire. This slows the agent down, as the velocity is reset to 0 every step. A flat tire lasts until the end of the episode.Version Historyv0: initial release
Package: pgtg-widgets
pgtg_widgetsit will help you quickly and easily create a user interface for your PyGame applicationtry to start example_demonstration.py as mainavailable widgets:advice: sx/sy should be in range [1.8; 3] - these are the most elegant proportionssc - should be pygame surfacex, y - coordinates on surface as in pygame (only int)sx, sy - sizes of element as in pygame (only int)grad - the degree of opacity of the elementborder - border width in px (only int)Switchcol_bor, col_off, col_on - rgb colors of border, right half and left halfstate - state of switch (bool)time_tick - delay between ticksButtoncolor - color of buttontext, font, text_color - button text settingsProgressBarcol_bor, col_off, col_on - rgb colors of border, right half and left half
Package: pgtool
PGtool is a command-line tool designed to simplify some common maintenance tasks on PostgreSQL databases. It works with
Python 2.7 and 3.3+ using the psycopg2 driver.Available commands:cp SOURCE DESTUses CREATE DATABASE … TEMPLATE to create a duplicate of a database. Additionally copies over database-specific
settings.When used with –force, an existing database with the same name as DEST is replaced, the original is renamed out of
place in the form DEST_old_YYYYMMDD (unless –no-backup is specified).mv SOURCE DESTRename a database within a server.When used with –force, an existing database with the same name as DEST is replaced, the original is renamed out of
place in the form DEST_old_YYYYMMDD (unless –no-backup is specified).kill DBNAME [DBNAME …]Kills all active connections to the specified database(s).reindex IDXNAME [IDXNAME …]Uses CREATE INDEX CONCURRENTLY to create a duplicate index, then tries to swap the new index for the original.The index swap is done using a short lock timeout to prevent it from interfering with running queries. Retries until
the rename succeeds.Resourceshttps://github.com/voicecom/pgtoolhttps://pypi.python.org/pypi/pgtoolChangelog0.0.1 (2015-10-26)Initial public release, commands: ‘cp’, ‘mv’, ‘kill’ & ‘reindex’ContributingCode style:In general follow the PythonPEP-8coding style, except line length can go up to 120 chars.Strings that have meaning for humans use double quotes ("), otherwise single quotes ('). When in doubt, don’t
worry about it.Code should be compatible with both Python 2 and 3, preferably without version-specific conditionals.Run the test suite usingpython setup.py test.Submit your changes as pull requests on GitHub.LicenseCopyright 2015 Voicecom, Marti Raudsepp & contributorsLicensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttps://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Package: pgtoolkit
pgtoolkitprovides implementations to manage various file formats in Postgres
cluster. Currently:postgresql.conf: read, edit, save.pg_hba.conf: render, validate and align columns..pgpass: render, validate and sort lines.pg_service.conf: find, read, edit, render.Cluster logs.It also provides a Python API for callingpg_ctlcommands.import sys

from pgtoolkit.hba import parse


with open('pg_hba.conf') as fo:
    hba = parse(fo)

hba.write(sys.stdout)The API in this toolkit must:Use only Python stdlib.Use Postgres idioms.Have full test coverage.Run everywhere.Supportpgtoolkithome on GitHub is the unique
way of interacting with developers. Feel free to open an issue to get support.
Package: pgtree
pgtreeUnix process hierachy tree display for specific processes (kind of mixed pgrep + pstree)pgtree is also able to send signal to found processes and all their childrenThe purpose is to have the tool working out of the box on any Unix box, using the default OS python installed, without installing anything else.
The code must be compatible with python 2.x + 3.xShould work on any Unix that can execute :# /usr/bin/pgrep 
# /usr/bin/ps -e -o pid,ppid,stime,user,ucomm,argsifpgrepcommand not available (AIX), pgtree uses built-in pgrep (-f -i -x -u <user>supported).Tested on various versions of RedHat / CentOS / Ubuntu / Debian / Suse / MacOS / Solaris / AIX including old versions(uses -o comm on Solaris)InstallationFYI, thepgtree/pgtree.pyis standalone and can be directly copied/used anywhere without any installation.installation using pip:# pip install pgtreeinstallation using setup.py, root install in/usr/local/bin:# ./setup.py installinstallation using setup.py, user install in~/.local/bin:# ./setup.py install --prefix=~/.localUsage# pgtree -h
    usage: pgtree.py [-W] [-RIya] [-C <when>] [-O <psfield>] [-c|-k|-K] [-1|-p <pid1>,...|<pgrep args>]

    -I : use -o uid instead of -o user for ps command
         (if uid/user mapping is broken ps command can be stuck)
    -c : display processes and children only 
    -k : kill -TERM processes and children
    -K : kill -KILL processes and children
    -y : do not ask for confirmation to kill
    -R : force use of internal pgrep
    -C : color preference : y/yes/always or n/no/never (default auto)
    -w : tty wrap text : y/yes or n/no (default y)
    -W : watch and follow process tree every 2s
    -a : use ascii characters
    -O <psfield>[,psfield,...] : display multiple <psfield> instead of 'stime' in output
                   <psfield> must be valid with ps -o <psfield> command

    by default display full process hierarchy (parents + children of selected processes)

    -p <pids> : select processes pids to display hierarchy (default 0)
    -1 : display hierachy children of pid 1 (not including pid 0)
    <pgrep args> : use pgrep to select processes (see pgrep -h)

    found pids are prefixed with ▶Examplesshow all parents and children of processes matchingbashshow processes matchingbashand their childrenkill allshprocesses of user joknarf and their childrenCustomize ps output fields:Put default options in PGTREE env variable:# export PGTREE='-1 -O %cpu,stime -C y'
# pgtreeUse watch utility to follow process tree:# pgtree -W bashDemo
Package: pgtricks
This package contains two tools for backing up PostgreSQL database dumps.InstallingTo install in a virtualenv or globally as a superuser:pip install pgtricksTo install only for the current user:pip install --user pgtrickspg_dump_splitsortpg_dump_splitsortis a handy script for pre-processing PostgreSQL’spg_dumpoutput to make it more suitable for diffing and storing in version
control.Usage:pg_dump_splitsort <filename>.sqlThe script splits the dump into the following files:0000_prologue.sql:
everything up to the first COPY0001_<schema>.<table>.sql::NNNN_<schema>.<table>.sql:
COPY data for each tablesorted by the first field9999_epilogue.sql:
everything after the last COPYThe files for table data are numbered so a simple sorted concatenation of all
files can be used to re-create the database:$ cat *.sql | psql <database>I’ve found that a good way to take a quick look at differences between dumps is
to use themeldtool on the whole directory:$ meld old-dump/ new-dump/Storing the dump in version control also gives a decent view on the
differences. Here’s how to configure git to use color in diffs:# ~/.gitconfig
[color]
        diff = true
[color "diff"]
        frag = white blue bold
        meta = white green bold
        commit = white red boldNote:If you have created/dropped/renamed tables, remember to delete all.sqlfiles before post-processing the new dump.pg_incremental_backupThepg_incremental_backupscriptmakes a database dump usingpg_dumpsplits the dump into per-table files usingpg_dump_splitsortcreates or commits changes into a local Git repository containing the dumppushes the changes to the remote repositoryUsage:pg_incremental_backup [-h] [--output-dir OUTPUT_DIR] database [remote]

positional arguments:
  database
  remote

optional arguments:
  -h, --help            show this help message and exit
  --output-dir OUTPUT_DIR, -o OUTPUT_DIR
Package: pgtty
PgTTYA terminal for Python using Pygame.To install, runpip3 install pgttyNote: If you are using Python3.11, you need to runpip3 install pygame --prefirst.UsageTo initialise pgtty, rundisplay = pgtty.PgTTY()There is an example program inmain.pyin the github repository.The main functions are:display.print(text)This prints to the screen based on where the pointer is. Optional arguments are foreground and background in the form (r, g, b) to add color. This function automatically runsdisplay.update()after.display.input() -> strThis asks the user for input. Returns a string of what they typed once they press enter.display.set((y, x), char)This sets a certain character on the screen atx, ytochar. It also supports foreground and background colors as mentioned above.Note: This does not update the screen, you have to rundisplay.update()after.display.update()This updates the screen.display.foreground = (127, 127, 127)This is a variable set to grey as default. This is the default foreground color of the text you print or set, unless specified in keyword arguments.display.background = (0, 0, 0)Same as foreground, but in the backgrounddisplay.pointer = (y, x)This defines where the pointer is fordisplay.print()Version Log:v0.2.1:Added inputImproved README and example programv0.1.1:Improved README and example programv0.1.0:First versionAdded print, set, update, scroll
Package: pg-tuna
pg-tunaPostgreSQL + <({(>(pg-tuna is a cli program to generate optimal PostgreSQL and AWS PostgreSQL RDS
settings. It outputs for AWS RDS already the needed units conversion so the
settings can be easily applied.It is based on excelent work of:https://github.com/le0pard/pgtunehttps://github.com/gregs1104/pgtuneThis tool only supports Linux there is no option to choose any other platform
and why ;)Install && run$ pip install pg-tunaRun it like:$ pg-tuna --db-type web  --db-version 11 --memory 8 --cpu-num 8 --disk-type ssd

#-------------------------------------------------------------------------------------------------------------------------
# pg-tuna run on 2023-06-28
# Settings used: db_type = web | db_version = 11 | connections = None | total_memory = 8 | cpu_num = 8 | disk_type = ssd 
# Based on 8 GB RAM, platform Linux, 200 clients and web workload
#---------------------------------------------------------- PG ----------------------------------------------------------

 max_connections = 200
 random_page_cost = 1.1
 shared_buffers = 2048 MB
 effective_cache_size = 6144 MB
 work_mem = 2621 kB
 maintenance_work_mem = 512 MB
 min_wal_size = 1024 MB
 max_wal_size = 4096 MB
 checkpoint_completion_target = 0.9
 wal_buffers = 16 MB
 default_statistics_target = 100
 max_parallel_workers_per_gather = 4.0
 max_worker_processes = 8
 max_parallel_workers = 8
 max_parallel_maintenance_workers = 4.0

#---------------------------------------------------------- AWS ----------------------------------------------------------

 max_connections = 200
 random_page_cost = 1.1
 shared_buffers = 262144 pages (8kB)
 effective_cache_size = 786432 pages (8kB)
 work_mem = 2621 kB
 maintenance_work_mem = 524288 kB
 min_wal_size = 1024 MB
 max_wal_size = 4096 MB
 checkpoint_completion_target = 0.9
 wal_buffers = 2048 pages (8kB)
 default_statistics_target = 100
 max_parallel_workers_per_gather = 4.0
 max_worker_processes = 8
 max_parallel_workers = 8
 max_parallel_maintenance_workers = 4.0Debugging performanceTo debug performance issues we first need to indentify the slow queries. Then
we can start benchmarking them and apply changes to our code (adding indexes,
modify our ERM , or apply optimized settings to PostgreSQL)To test queries PostgreSQL has a nice toolpgbench. If you like me can't ssh into
the PostgreSQL server and you don't like to install PostgreSQL to getpgbenchuse the includedDockerfile(it will only create a 8MB image).https://www.PostgreSQLql.org/docs/10/pgbench.htmlpgbench$dockerbuild-tpg_tuna/pgbench.Set settings inenv.listto connect to your PostgreSQL instanceWe use a query defined inbench/select_count.sqlto run our performance
tests.Run$ docker run -it --env-file ./env.list -v `pwd`/bench:/var/bench pg_tuna/pgbench pgbench -c 10 -j 4 -t 100 -f /var/bench/select_count.sqlRun via local jumphost$ docker run -it --network="host" --env-file ./env.list -v `pwd`/bench:/var/bench pg_tuna/pgbench pgbench -c 10 -j 4 -t 100 -f /var/bench/select_count.sqlDeploy$pipinstallbuildtwine
$python-mbuild
$twineupload-rpypidist/*
Package: pgu
Phil’s pyGame Utilities - a collection of handy modules and scripts for PyGame.tileedit  – edit tga based images
leveledit – edit tga based levels in tile, isometric, and hexagonal formatsgui     – gui with standard widget, dialog, connections, and themes
html    – html rendering utilities
layout  – layout utilities
text    – text rendering utilitiestilevid – sprite and tile engine
isovid  – isometric sprite and tile engine
hexvid  – hexagonal sprite and tile engine
engine  – state engine
timer   – a timer for games with set-rate FPS
high    – high score tracking
ani     – animation helpers
algo    – helpful pathfinding algoritms
fonts   – font wrappers, bitmapped fonts
Package: pguard
Guard like Haskell for Python.StatusRequirementsPython 2.7 or Python 3.6 over or PyPy 2.4.0 overFeaturesguard with lambdaEnable to use function or method asguard_clstatement argument.Setup$ pip install --user pguard
or
(venv)$ pip install pguardSimple usage>>> from pguard import guard
>>> from pguard import guard_cl as g
>>> (lambda n: guard(
... g(-1, n < 0),
... g(0, n == 0),
... g(1)  ## otherwise
... ))(0)
0ChangeLog0.4.0 (2019-03-18)Supports Python 3.7.Drops Python 2.7, Python 3.5.0.3.1 (2018-11-03)Fixes pylint violations.0.3.0 (2016-04-30)Fixes lazy evaluation.Changes guard_cl() respond values.0.2.1 (2016-04-29)Fixes Python 2.7 classmethod behavior bugs.0.2.0 (2016-04-27)Supports “function” and “method” as guard_cl statement argument.0.1.4 (2016-04-24)Fixes setup.py url.0.1.3 (2016-04-23)Fixes README.Adds check long-description to pre-commit hook.0.1.2 (2016-04-23)Fixes setup.py version.0.1.1 (2016-04-23)completed coverage 100%.Adds sample usages.0.1.0 (2016-04-23)Initial release.