Saravanan666/pypi-org huggingface dataset:
Package: python-spymock
spymockThis library providesSpyMockwhich is similar toMagicMockbut recording function return values and exceptions oncall_values_or_exceptionsattribute.Installationpip install python-spymockUsageUsespymock.spyfunction as-likepatch.objectto spy and mock the target attribute like:importurllib.requestfromspymockimportspydefrequest():url="http://httpbin.org/json"req=urllib.request.Request(url)withurllib.request.urlopen(req)asres:returnjson.loads(res.read())deftest_request_with_spy():withspy(urllib.request,"urlopen")ass:assertrequest()=={"slideshow":{"author":"Yours Truly","date":"date of publication","slides":[{"title":"Wake up to WonderWidgets!","type":"all"},{"items":["Why <em>WonderWidgets</em> are great","Who <em>buys</em> WonderWidgets",],"title":"Overview","type":"all",},],"title":"Sample Slide Show",}}# 's' is like MagicMock but it has 'call_values_or_exceptions' attributeassertlen(s.call_values_or_exceptions)==1r=s.call_values_or_exceptions[0]assertisinstance(r,HTTPResponse)assertr.status==200assertr.reason=="OK"Or directly createspymock.SpyMockinstance as-likeMagicMocklike:importurllib.requestfromspymockimportSpyMockdefrequest():url="http://httpbin.org/json"req=urllib.request.Request(url)withurllib.request.urlopen(req)asres:returnjson.loads(res.read())deftest_request_with_spymock():s=SpyMock(request)asserts()=={"slideshow":{"author":"Yours Truly","date":"date of publication","slides":[{"title":"Wake up to WonderWidgets!","type":"all"},{"items":["Why <em>WonderWidgets</em> are great","Who <em>buys</em> WonderWidgets",],"title":"Overview","type":"all",},],"title":"Sample Slide Show",}}# 's' is like MagicMock but it has 'call_values_or_exceptions' attributeassertlen(s.call_values_or_exceptions)==1r=s.call_values_or_exceptions[0]assertr=={"slideshow":{"author":"Yours Truly","date":"date of publication","slides":[{"title":"Wake up to WonderWidgets!","type":"all"},{"items":["Why <em>WonderWidgets</em> are great","Who <em>buys</em> WonderWidgets",],"title":"Overview","type":"all",},],"title":"Sample Slide Show",}}LicenseDistributed under the terms of theMIT license.
Package: python-sql-abstraction
All SQL modules written in python follows a standard DB-API 2.0.Thus all connections attributes and methods can be used for different SQL engines.An abstract class, “Database” was created in order for sub classes that inherit this class to re-implement the __init__ method in order to set a connection.Since connections is loaded differently for each SQL engine.Attribute Connection was made private in order not to change it from a different layer and to keep the connection consistent.Python 3.2 requiredExample:from Databases.SQLite import SQLiteDatabasedb = SQLiteDatabase(None, ‘test.db’)results = db.select(‘table_name’, [‘name’, ‘id’])
Package: python-sql-faker
Data Structure Creation withsql-fakersql-fakeris a python library that can be used to generate relational data structures and fill these structures with fake data.
It is built upon python librarysqlfakermade bykohleggermichael.sql-fakerfeatures Oracle SQL export support, enhanced handling ofFakermethods and better foreign key generation.InstallationComing soonClass structureThis project lets you define relational data structures that are build upon the concepts ofDatabase,TableandColumn.ADatabasecan have multipleTableobjects which again can each have multipleColumnobjects.
There are two classes that inherit from theColumnclass -ForeignKeyandPrimaryKey. These allow you to create key columns.CreditsMade possible thanks tokohleggermichaeland his packagesqlfaker
Package: python-SQLGrants
SQL Grants librarySupported databases:MySQLExamples of UsageInstallationpython-mpipinstallpython-sqlgrantsSet and revoke grantsfromsqlgrants.mysqlimportMySQL,GrantTypemysql=MySQL('root','secret')grant_types={GrantType.SELECT,GrantType.INSERT}# Revoke grantsmysql.revoke({GrantType.ALL},username='username',schema='mysql')assertmysql.show_grants(username='username',schema='mysql')=={GrantType.USAGE}# Set grantsgrants_set={GrantType.SELECT,GrantType.INSERT}mysql.grant({GrantType.SELECT,GrantType.INSERT},username='username',schema='mysql')assertmysql.show_grants(username='username',schema='mysql')==grants_setShow grants on tables and schemasfrompprintimportpprintfromsqlgrants.mysqlimportMySQL,GrantTypemysql=MySQL('root','secret')grants=mysql.tables_grants('user','%','tests')pprint(grants)# {'tests': {'test_table_1': {SELECT, INSERT, UPDATE},#            'test_table_2': {SELECT, INSERT},#            'test_table_3': {SELECT, INSERT}}}
Package: python-sqlite-cache
# python-sqlite-cacheSQlite Cache module## RequirementsPython 3.6+## Install~~~
$ pip install python-sqlite-cache
~~~## Usage### Initialize#### In Memory~~~
> from sqlite_cache.sqlite_cache import SqliteCache
> sql_cache = SqliteCache()
~~~#### On Disk~~~
> from sqlite_cache.sqlite_cache import SqliteCache
> sql_cache = SqliteCache(path_cache_dir)
~~~### Usage~~~
> sql_cache.set(‘some_key’)
> print(sql_cache_get(‘some_key’, ‘some_value’))
some_value
~~~
Package: pythonsqlparser
SQL ParserThis package convert SQL string into a syntax tree object.These objects can then be manipulated via Python's code.The SQL syntax used is the one used by Apache Spark, based on Presto's one.It is defined insrc/sqlparser/grammar/SqlBase.g4.Usagefromsqlparserimportparse_statementfromsqlparser.utilsimportprint_treetree=parse_statement('SELECT * FROM table WHERE column LIKE "%Python%"')print_tree(tree)Result (each line is a node of the tree):|SingleStatementContext
|-StatementDefaultContext
|--QueryContext
|---QueryTermDefaultContext
|----QueryPrimaryDefaultContext
|-----RegularQuerySpecificationContext
|------SelectClauseContext
|-------TerminalNodeImpl[SELECT]
|-------NamedExpressionSeqContext
|--------NamedExpressionContext
|---------ExpressionContext
|----------PredicatedContext
|-----------ValueExpressionDefaultContext
|------------StarContext
|-------------TerminalNodeImpl[*]
|------FromClauseContext
|-------TerminalNodeImpl[FROM]
|-------RelationContext
|--------TableNameContext
|---------MultipartIdentifierContext
|----------ErrorCapturingIdentifierContext
|-----------IdentifierContext
|------------UnquotedIdentifierContext
|-------------NonReservedContext
|--------------TerminalNodeImpl[table]
|-----------RealIdentContext
|---------TableAliasContext
|------WhereClauseContext
|-------TerminalNodeImpl[WHERE]
|-------PredicatedContext
|--------ValueExpressionDefaultContext
|---------ColumnReferenceContext
|----------IdentifierContext
|-----------UnquotedIdentifierContext
|------------NonReservedContext
|-------------TerminalNodeImpl[column]
|--------PredicateContext
|---------TerminalNodeImpl[LIKE]
|---------ValueExpressionDefaultContext
|----------ConstantDefaultContext
|-----------StringLiteralContext
|------------TerminalNodeImpl["%Python%"]
|---QueryOrganizationContext
|-TerminalNodeImpl[<EOF>]
Package: python-sqlparser
python-sqlparserA Python Module for the "General SQL Parser" library (sqlparser.com)Referhttps://github.com/TwoLaid/python-sqlparserSupported SystemsThis library currently supports: Windows 32bit/64bit and Linux 32bit/64bit.
There are currently no binaries for Mac OSX available.This module support Python 2.* and Python 3.*InstallationSimply clone or download this git and executepip install python-sqlparserThe setup script will automatically download the right library (from sqlparser.com) for you.UsageSimply import the module with
import sqlparser
The following example will parse a simple query:importsqlparserquery="SELECT a, b FROM table_1 WHERE c > 20"# Init a oracle sql parserparser=sqlparser.Parser(vendor=2)# Check for syntax errorsifparser.check_syntax(query)==0:# Get first statement from the querystmt=parser.get_statement(0)# Get root noderoot=stmt.get_root()print(root.__dict__)And print the node information the SELECT node:{"computeClause":None,"cteList":None,"expandOnClause":None,"fetchFirstClause":None,"forupdateClause":None,"fromTableList":<sqlparser.Nodeobjectat0x7ff48c5eed50>,"groupByClause":None,"hierarchicalClause":None,"intoClause":None,"intoTableClause":None,"isolationClause":None,"leftNode":None,"limitClause":None,"lockingClause":None,"node_type":5,"optimizeForClause":None,"orderbyClause":None,"qualifyClause":None,"resultColumnList":<sqlparser.Nodeobjectat0x7ff48c5ee618>,"rightNode":None,"sampleClause":None,"selectDistinct":None,"selectToken":"SELECT","setOperator":0,"topClause":None,"valueClause":None,"whereCondition":<sqlparser.Nodeobjectat0x7ff48c5eea78>,"windowClause":None,"withClauses":None}ExamplesFor more examples please check the examples directory.
Package: python-sqs-consumer
docstestspackageAn example package. Replace this with a proper project description. Generated withhttps://github.com/ionelmc/cookiecutter-pylibraryFree software: BSD licenseInstallationpip install python_sqs_consumerDocumentationhttps://python-sqs-consumer.readthedocs.org/DevelopmentTo run the all tests run:tox
Package: python-srtm
NASA SRTM altitude data parsing in PythonProvides an API onto SRTM.hgtor.hgt.zipfiles.Requires Python 3.8,maywork with Python 3.6 & 3.7.Installationpip install python-srtm

export SRTM1_DIR=/path/to/srtm1/
export SRTM3_DIR=/path/to/srtm3/UseYou can access either SRTM1 or SRTM3 data. SRTM 1, for example:# SRTM1 - 30m resolution>>>fromsrtmimportSrtm1HeightMapCollection>>>srtm1_data=Srtm1HeightMapCollection()>>>srtm1_data.get_altitude(latitude=40.123,longitude=-7.456)615>>>Srtm1HeightMapCollection().get_elevation_profile(40.123,-7.456,40.129,-7.460)[615,620,618,620,616,603,593,582,575,579,580,589,589,581,565,553,545,541,534,533,529,520,514]Or SRTM3:# SRTM3 - 90m resolution>>>fromsrtmimportSrtm3HeightMapCollection>>>srtm3_data=Srtm3HeightMapCollection()>>>srtm3_data.get_altitude(latitude=40.123,longitude=-7.456)608>>>Srtm3HeightMapCollection().get_elevation_profile(40.123,-7.456,40.129,-7.460)[626,616,585,593,577,548,528,514]ProfilingimportcProfilecProfile.run('function_to_profile()',filename='output.cprof')brewinstallqcachegrind
pipinstallpyprof2calltree
pyprof2calltree-k-i/pythonprofiling/profiler/first_iteration.cprofRelease processFor internal reference:# Run the tests
pytest

export VERSION="VERSION HERE"

# Version bump
poetry version $VERSION

# Update the setup.py
dephell convert
black setup.py

# Ensure poetry.lock is up to date
poetry lock

# Commit
git add .
git commit -m "Releasing version $VERSION"

# Tagging and branching
git tag "v$VERSION"
git branch "v$VERSION"
git push origin \
    refs/tags/"v$VERSION" \
    refs/heads/"v$VERSION" \
    master

poetry publish --build
Package: python-sscma
Python SSCMA-MicroDescriptionThis is a client for thesscma_micro, which is a
microcontroller at server for theSSCMAmodels.More information about the sscma_micro can be found athereUsageInstallpipinstallpython-sscmafromsscma.micro.clientimportClient,SerialClientfromsscma.micro.deviceimportDevicefromsscma.micro.constimport*importserialimportthreadingimporttimeimportloggingimportsignalimportcv2importbase64importnumpyasnplogging.basicConfig(level=logging.DEBUG)_LOGGER=logging.getLogger(__name__)defmonitor_handler(device,msg):if"image"inmsg:jpeg_bytes=base64.b64decode(msg["image"])# Convert the bytes into a numpy arraynparr=np.frombuffer(jpeg_bytes,np.uint8)# Decode the image array using OpenCVimg=cv2.imdecode(nparr,cv2.IMREAD_COLOR)# Display the imagecv2.imshow('Base64 Image',img)cv2.waitKey(1)msg.pop("image")print(msg)defon_device_connect(device):print("device connected")device.Invoke(-1,False,True)device.tscore=70device.tiou=70client=SerialClient("COM83")defsignal_handler(signal,frame):print("Ctrl+C pressed!")client.loop_stop()defmain():signal.signal(signal.SIGINT,signal_handler)device=Device(client)device.on_monitor=monitor_handlerdevice.on_connect=on_device_connectdevice.loop_start()print(device.info)i=60whileTrue:print(device.wifi)print(device.mqtt)print(device.info)print(device.model)device.tscore=idevice.tiou=ii=i+1ifi>100:i=30time.sleep(2)if__name__=="__main__":main()ContributingIf you have any idea or suggestion, please open an issue first.If you want to contribute code, please fork this repository and submit a pull
request.LicenseMIT License
Package: python-ssdb
# python-ssdb
The python client for [SSDB](https://github.com/ideawu/ssdb) Key-Value store.## Installation`shell $ pip installpython-ssdb`## Features
- Use compiled response parser written in Cython.
- Supports connection pool.
- Supports async API.## Usage### Basic example`python >>> from ssdb import SSDB >>> cli =SSDB(host="localhost",port=7036) >>>cli.set("foo","bar") 1 >>>cli.get("foo")b'bar' `## Commands
- Supports all commands in [this page](https://ssdb.io/docs/php/)## LicenseThis software is licensed under the [Apache 2 license](LICENSE), quoted below.Copyright 2023 Kakao Corp. <http://www.kakaocorp.com>Licensed under the Apache License, Version 2.0 (the “License”); you may not
use this project except in compliance with the License. You may obtain a copy
of the License athttp://www.apache.org/licenses/LICENSE-2.0.Unless 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: python-ssh-exec
Python SSH ExecutionPython library for executing local Python scripts on remote machines.InstallationUse the package managerpipto install foobar.pipinstallpython-ssh-execUsagepyssh-f~/path/to/script.py-hSERVER_ADDRESS-pPORT-uUSERNAME-pwPASSWORDContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.LicenseMIT
Package: python-sshtail
A simple set of Python classes to facilitate tailing of one or more files via SSH.
At the moment it only supports key-based SSH’ing.Quick installationInstall from PyPI:> easy_install -U python-sshtailTailing a single filefrom sshtail import SSHTailer
from time import sleep

# "1.2.3.4" is the IP address or host name you want to access
tailer = SSHTailer('1.2.3.4', '/var/log/path/to/my/logfile.log')

try:
    while 1:
        for line in tailer.tail():
            print line

        # wait a bit
        time.sleep(1)

except:
    tailer.disconnect()Tailing multiple filesfrom sshtail import SSHMultiTailer

tailer = SSHMultiTailer({
    '1.2.3.4': ['/path/to/log1.log', '/path/to/log2.log'],
    '4.3.2.1': ['/path/to/log3.log'],
})

# will run until it receives SIGINT, after which it will
# automatically catch the exception, disconnect from the
# remote hosts and perform cleanup

for host, filename, line in tailer.tail():
    print "%s:%s - %s" % (host, filename, line)Using a custom private keyfrom sshtail import SSHMultiTailer, load_dss_key

# if no path's specified for the private key file name,
# it automatically prepends /home/<current_user>/.ssh/
# and for RSA keys, import load_rsa_key instead.

tailer = SSHMultiTailer({
        '1.2.3.4': ['/path/to/log1.log', '/path/to/log2.log'],
        '4.3.2.1': ['/path/to/log3.log'],
    },
    private_key=load_dss_key('identity'))

for host, filename, line in tailer.tail():
    print "%s:%s - %s" % (host, filename, line)
Package: pythonssl
PySSL moduleHelp for:Create a certificate file and a private key file for TLS/SSL.Missing:Sure. Security is an important issue in IoT MQTT. Me too. I believe this module will meet your business needs with RSA algorithm (with 2048 bits or more)Feature:Generate RSA key with key size greater than or equal by 2048 bits
Supported for SHA algorithms (SHA1, SHA244, SHA256, … SHA512_256)Command:!exit: for end the current action.
[enter] key: for pass the current inputDocumentation:https://github.com/phucbao9x/pyssl/blob/main/README.mdIssue:https://github.com/phucbao9x/pyssl/issues
Package: python-ssmi
python-ssmiThis is a python module implementing TruTeq’s SSMI protocol for USSD and SMS.This was implemented from SSMI version 1.5.9 documentation which is copyright
TruTeq Wireless (Pty) Ltd 2001-2003.setting up buildoutThis module follows the buildout instructions documented athttp://jacobian.org/writing/django-apps-with-buildout/To initialise buildout run:
$ python bootstrap.pyThen run buildout:
$ ./bin/buildoutgenerating releasesCreate a source tarball:
$ ./bin/buildout setup . sdistCreate an egg:
$ ./bin/buildout setup . bdist_egg
Package: python-stack
stackis a Python version ofstack(http://docs.haskellstack.org/en/stable/README/), which is a cross-platform program for developingPythonprojects. It is aimed atPythonistasboth new and experienced.Go StarStack on GitHub(http://github.com/ryankung/stack)It features:Install Python in current environment automatically, in an isolated locationInstalling packages needed for your project.Run your projectCheck test coverage of your projectCode quality controlEnd to End git based releaseInclude:stack / pystackstack-cli – The core part of stackscaffold  – A Python template generatorrequire  – An async remote module loaderDependence:Python3.5 or above (may require libffi-devel oncentos, or libffi-dev fordebian)git-daemon (https://git-scm.com/book/en/Git-on-the-Server-Git-Daemon)Quick Start:Installation:pip3 install python-stack

or run

curl "https://raw.githubusercontent.com/RyanKung/stack/master/install.sh" | shCreate a new project via template:stack new <project name> -t <template path>Init and Setup on an existed project:stack init --python=<spec version>
stack setupTest and report test coverage:stack coverageRun executable file in Env:stack python
stack pip
stack test
stack replRun a remote file:stack run --run <some *.py remote>Extensible:Stack supports extending the environment with a stackfile like this:


from stack.decorators import as_command

@as_command
def do(args):
    '''
    sth
    @argument --sth, help=dowhat
    '''
    print('do %s' % args.sth)Document generator:stack docad-hoc git baseed deployment:on remote production server:stack serveon local dev environment:git add remote production git://<your remote ip>:30976/.git
git checkout release/<your release branch>
git push production HEADWork with stackfilestackfilestackfile is a local config file like makefile/gruntfile/glupfile/etc., thestack-cliwill automacily load in the stackfile when boot.decoratorsFor the newest version ofstack-cli, there is two useful decorators:@as_commandand@wsh_command, the first decorator allows function be called as stack command, and thewsh_commanddecorator can map a local command function to a remote callable function. Which means that you can call the command viastack wshorrestful apiof stack cli
Package: python-stackato
Python-Stackato===============[![PyPi version](https://pypip.in/v/python-stackato/badge.png)](https://crate.io/packages/python-stackato/)[![PyPi downloads](https://pypip.in/d/python-stackato/badge.png)](https://crate.io/packages/python-stackato/)A wrapper to the Stackato Client API. Allows users to make requests to the Stackato API. Easy Peasy Lemon Squeezy.To read up more on the Stackato Client API, please see the documentation [here](http://docs.stackato.com/api/client.html).## Installationpip install python-stackatoalternatively...git clone https://github.com/bacongobbler/python-stackatopython setup.py install## UsageTake a look at the examples/ folder for some real-life examples.### Logging into the client```pythonfrom stackato import Sessions = Session("https://api.stackato-xxxx.local/")s.login("username", "password")```### Passwordless AuthenticationThis is for when you have previously logged in and the token is storedwithin your client token file (hidden at ~/.stackato/client/token)```pythonfrom stackato import Sessions = Session("https://api.stacka.to/")if s.login():print(s._get('info'))```### Storing the authentication token locally, and deleting an app```pythonfrom stackato import Session# Spot the difference!s = Session("https://api.stackato-xxxx.local/")if s.login(store_token=True):s.delete_app('demo')```### Lisng all services bound to an app```pythonfrom stackato import Sessions = Session("https://api.stackato-xxxx.local/")if s.login():print(s.get_app('demo').services)```### Forcing your app to increase its number of instances by one```pythonfrom stackato import Sessions = Session("https://api.stackato-xxxx.local/")if s.login():app = s.get_app('demo')app['instances'] += 1# make a PUT request to the applicationif s.put_app('demo', app):print('added one more instance to this application.')```### Making a custom GET requestThis will also work with _post(), _put(), and _delete(). You can also take a look at _request() if you want to make your own custom request call.```pythonfrom stackato import Sessions = Session("https://api.stackato-xxxx.local/")if s.login():print(s._get('stackato/usage?all=1'))```
Package: python-stackdriver-logging-mdp1
Logging library for Python using StackdriverReference for good logginghereCheck out 'Write logging records everywhere with a proper level' sectionTo use logging:Copy logging.yaml and stackdriver.py into the project you want to useIn order to import the logger, 'from stackdriver import stackdriver_logger'In order to initialize the logger, 'mdp_logger = stackdriver_logger()'In order to use the logger, 'mdp_logger.info('shows up on stackdriver and console')'Logging Levels in current configuration (set in logging.yaml)debug: lowest level and logs of these kinds don't show up as of current configurationinfo: info logs will show up on stdout and in stackdriverwarning: warn logs will show up on stdout and in stackdrivererror: error logs will show up on stdout and in stackdrtivercritical: critical logs will show up on stdout and in stackdriverChange log level that shows up in StackdriverIn logging.yaml, under handlers:stackdriver, change the level field to the lowest level you want to see in stackdriver.
Anything that level and higher will now show up.Change log level that shows up on consoleIn logging.yaml, under handlers:console, change the level field to the lowest level you want to see show up in console.
Anything that level and higher will now show up.
Package: python-stackhelper
# Useful OpenStack Helper Commands## Install~~~pip install python-stackhelper~~~## Usage:### Security Group Synchronization~~~$ stackhelper secgroup-sync --secgroup-json secgroups.example.jsonDeleting group: testingCreating group: chefCreating group: haproxyCreating group: aptCreate rule ALLOW tcp/80-80 FROM 'chef' in group 'apt'Create rule ALLOW tcp/80-80 FROM 'haproxy' in group 'apt'Create rule ALLOW tcp/4000-4000 FROM 'apt' in group 'chef'Create rule ALLOW tcp/4000-4000 FROM 'haproxy' in group 'chef'Create rule ALLOW tcp/443-443 FROM '0.0.0.0/0' in group 'haproxy'$ nova secgroup-add-rule chef tcp 100 200 0.0.0.0/0+-------------+-----------+---------+-----------+--------------+| IP Protocol | From Port | To Port | IP Range  | Source Group |+-------------+-----------+---------+-----------+--------------+| tcp         | 100       | 200     | 0.0.0.0/0 |              |+-------------+-----------+---------+-----------+--------------+$ stackhelper secgroup-sync --secgroup-json secgroups.example.jsonDelete rule ALLOW tcp/100-200 in group 'chef'~~~# Credential ManagementNo OS_ vars~~~$ env | grep OS_$~~~Run stackhelper (inside backticks)~~~$ `stackhelper credentials hpcloud az1 exampleuser`~~~Check the OS_ env var's again:~~~$ env | grep OS_OS_REGION_NAME='az-1.region-b.geo-1'OS_TENANT_ID='...'OS_PASSWORD='...'OS_AUTH_URL='...'OS_USERNAME='...'OS_TENANT_NAME='...'~~~