Saravanan666/pypi-org huggingface dataset:
Package: cannon
Introduction[cannon][1] is a wrapper around [exscript][2] to connect with remote server or network
devices with ssh.Example Usage - Cisco IOSThis script will login, run a few show commands.  If you want an interactive session, setinteract=Truewhen calling Shell()importsysfromcannonimportShell,Accountfromloguruimportloggerlog_stderr_id=logger.add(sink=sys.stderr)@logger.catch(default=True,onerror=lambda_:sys.exit(1))defmain():sess=Shell(host='route-views.routeviews.org',# route-views doesn't need passwordaccount=Account(name='rviews',password=''),debug=0,json_logfile='/tmp/cmd_log.json',)sess.execute('term len 0')sess.execute('show clock')sess.execute('show version')version_text=sess.response# template is a TextFSM templatevalues=sess.execute('show ip int brief',template="""Value INTF (\S+)\nValue IPADDR (\S+)\nValue STATUS (up|down|administratively down)\nValue PROTO (up|down)\n\nStart\n^${INTF}\s+${IPADDR}\s+\w+\s+\w+\s+${STATUS}\s+${PROTO}-> Record""")print("VALUES "+str(values))sess.close()Example Usage - Linuxfromgetpassimportgetpassimportsysfromcannon.mainimportShell,Accountlog_stderr_id=logger.add(sink=sys.stderr)@logger.catch(default=True,onerror=lambda_:sys.exit(1))defmain():account=Account("mpenning",getpass("Login password: "))conn=Shell(host="127.0.0.1",port=22,account=account,driver="generic",debug=0)assertconnisnotNoneexample_tfsm_template="""Value UNAME_LINE (.+)Start^${UNAME_LINE}"""print(conn.execute("sudo uname -a",debug=0,template=example_tfsm_template,timeout=2))print(conn.execute("whoami",debug=0,template=None,timeout=2))#print("FOO2", conn.response)conn.close(force=True)if__name__=="__main__":main()Example test suite setupgit clone git@github.com:knipknap/ExscriptcdintoExscript/tests/Exscript/protocolsandchmod 600 id_rsaexscript spawns a local tests ssh daemon,pytest Exscript/tests/Exscript/protocols/SSH2Test.pyConnect withssh -i id_rsa -p 1236 user@localhostone command is supported:ls[1]:https://pypi.python.org/pypi/cannon# cannon on pypi
[2]:https://pypi.python.org/pypi/exscript# Exscript on pypi
Package: cannuckfind
title: CannuckfindCannuckfind is layered on top of large-scale multi-purpose projects. Its
main purpose is to provide a convient interface to the larger projects
with a goal to fascillitating the statistical analysis of informally
entered locational data.InstallationTo use cannuckfind, first install it using pip:PowerShell:: console$ pip install cannuckfindOptionsThis will install the package. The package will contain three modules
that can be imported for other uses:C3 - determine if text suggests a Canadian, US or other origin.geocasual - incorporate informal langauge.geolocation - error reporting system.ExampleHere we can test if a given city is in Canada.code-block:: Cannuckfind ===========Cannuckfind is layered on top of large-scale multi-purpose projects. Its
main purpose is to provide a convient interface to the larger projects
with a goal to fascillitating the statistical analysis of informally
entered locational data.InstallationTo use cannuckfind, first install it using pip:PowerShell:: console$ pip install cannuckfindOptionsThis will install the package. The package will contain three modules
that can be imported for other uses:C3 - determine if text suggests a Canadian, US or other origin.geocasual - incorporate informal langauge.geolocation - error reporting system.ExampleHere we can test if a given city is in Canada.code-block:import geograpy
import C3
demoC3 = C3.C3(useGEOGRPY = True)
print(demoC3.isCan('Toronto, Ontario'))
print(demoC3.isCan('Buffaloe, New York'))Will return a True of Toronto and a False for Buffaloe.Final NoteThis is still an early version.import geograpy import C3 demoC3 = C3.C3(useGEOGRPY = True)
print(demoC3.isCan('Toronto, Ontario'))
print(demoC3.isCan('Buffaloe, New York'))Will return a True of Toronto and a False for Buffaloe.Final NoteThis is still an early version.
Package: cannycam
CannyCamUses webcam stream and performs Canny Edge Detection and Haar Cascade image detection.Canny Edge Detection removes noise from image, giving black background and white outline. This accentuates sharp edges in the image, making it very easy to detect a target.Haar Cascade image detection actually detects the target, given a training set of positive images (pictures of the target) and negative images (pictures not containing target, should be images of the physical backgroud used for the experiment).Together, they take a video as a stream of images, to isolate and detect the target.Targets used: face, upper body, lower body, hands. Knee, elbow, smaller body parts are work in progress.Next step is to implement this into a diagnostic image detection program for assisting doctors. E.g. patient goes to doctor with broken ankle, doctor takes x-ray, diagnostic image detection program may be able to detect certain problems with patient's ankle upon scanning the x-ray.CannyCam. Better than a nannycam.InstallationpipinstallcannycamRunFrom the command linepython-mcannycam.cannycam
python-mcannycam.haarcam
python-mcannycam.cannyhaarcamOr in pythonimportcannycamcannycam.cannycam.main()cannycam.haarcam.main()cannycam.cannyhaarcam.main()
Package: cannyfier
# Real Time Video Reader
This project aims to read the video  from the computer screen and process it
using the Canny edges to detect lines.Allows to adjust the parameters of the Canny detection in real time through
slide vars.It is advisable to have 2 monitors (one being captured real time and another
that is showing the canny edges)When not having 2 monitors reduce the captured screen so the capture and The
canny fit in one screen.## Usage of the package
Start playing some video and then choose one of the options below. For example
if you want to work on traffic detection / signal detection you can use:https://www.youtube.com/watch?v=KmntziBBTrg### You don’t know the region to capturefrom cannyfier import get_capture_coords
from cannyfier import Cannyfier# This will create a window called InitWindow.
# 1. Move the window out of the view of the screen part you want to capture.
# 2. Click + Drag and Release in the window created to define the capture
#    box.
# 3. You can re-define the box by click again + drag and realease
# 4. Once satisfied with the capture box press q
ix, fx, iy, fy = get_capture_coords()# 5. This part will be executed then. The capture window will be displayed
#    with an smaller window with 2 slide bars
# 6. Move both windows out of the view of the capture box
# 7. Adjust the sliders to your taste of cannyfier
# 8. To finish the cannyfier press also q
my_cann = Cannyfier(ix, iy, fx, fy)# System will report you:
# 1. The region being captured (left, top, right bottom)
# 2. The average frames per second captured during the cannyfier process### You know the region to capture (x, y, x, y)from cannyfier import Cannyfier# Capture window will be displayed with an smaller window with 2 slide bars
# 1. Move both windows out of the view of the capture box
# 2. Adjust the sliders to your taste of cannyfier
# 3. To finish the cannyfier press also q
my_cann = Cannyfier(ix, iy, fx, fy)# System will report you:
# 1. The region being captured (left, top, right bottom)
# 2. The average frames per second captured during the cannyfier process## RemarksPress q to exit the program**<br>
**To define the box start always left top and end right bottom
Package: canomaly
canomalyProject DescriptionThis package detects specific types of anomalies with an emphasis in looking for cumulative changes.InstallationThis package can be installed throughPyPiusingpip install canomalyorpip3 install canomalyExample Usage>>>importpandasaspd>>>fromcanomaly.searchtoolsimportcumrexpy>>># Get some data>>>data={'date':['2018-11-20','2018-11-21','2018-11-22','2018-11-22','2018-11-23','2018-11-24'],'email':['john.doe@example.com','jane.smith@example.com','bob-johnson_123@example.com','sarah@mydomain.co.uk','frank@mydomain.com','jessica_lee@mydomain.com']}>>>df=pd.DataFrame(data)>>>df['date']=pd.to_datetime(df['date'])>>># Extract regular expressions>>>cumrexpy(df,'email','date')date2018-11-20[^john\.doe@example\.com$]2018-11-21[^[a-z]{4}\.[a-z]{3,5}@example\.com$]2018-11-22[^[a-z]{4,5}[.@][a-z]+[.@][a-z]+\.[a-z]{2,3}$,...2018-11-23[^frank@mydomain\.com$,^[a-z]{4,5}[.@][a-z]+[...2018-11-24[^frank@mydomain\.com$,^[a-z]+[.@_][a-z]+[.@]...Name:email_grouped,dtype:objectWe can look at the results in markdown for clarity.dateemail_grouped2018-11-20 00:00:00['^john\.doe@example\.com$']2018-11-21 00:00:00['^[a-z]{4}\.[a-z]{3,5}@example\.com$']2018-11-22 00:00:00['^[a-z]{4,5}[.@][a-z]+[.@][a-z]+\.[a-z]{2,3}$', '^bob\-johnson_123@example\.com$']2018-11-23 00:00:00['^frank@mydomain\.com$', '^[a-z]{4,5}[.@][a-z]+[.@][a-z]+\.[a-z]{2,3}$', '^bob\-johnson_123@example\.com$']2018-11-24 00:00:00['^frank@mydomain\.com$', '^[a-z]+[.@_][a-z]+[.@][a-z]+\.[a-z]{2,3}$', '^bob\-johnson_123@example\.com$']Build Documentation Locallycd/path/to/canomaly/docs
makehtml
Package: canonical-huffman-compression
Canonical Huffman CompressionThis implementation of the Huffman algorithm uses canonical code to save space. It is a full featured implementation that allows for the saving and loading of compressed files. It also allows for the use of a fixed dictionary, which can be useful in some situations.Using canonical Huffamn codes allows us to save the Huffman code dictionary with a combination of sorted symbols and the number occurrences for each code length. This is ideal for situations where the number of symbols used is significantly smaller than the number of possible symbols.Example of how to use the HuffmanCoding classThis implementation expects inputs as a list of integers. In this example, we convert some text to integers using the python ord function.fromcanonical_huffmanimportHuffmanCodingtext="Lorem ipsum dolor sit amet."data=[ord(char)forcharintext]huff=HuffmanCoding()huff.compress(data)huff.save_compressed('example.bin')# delete huff object and create a new one to show that there is no data leakage.delhuffhuff2=HuffmanCoding()huff2.open_compressed('example.bin')decompressed=huff2.decompress_file()ifdata==decompressed:print('huffman successful!')else:print('huffman failed!')Example of how to use a fixed dictionaryA fixed dictionary is sometimes used when the data is fairly predictable across files e.g. the distribution of common letters in the English language. Fixed dictionaries can sometimes save space when the size of the dictionary is large compared to the size of the data. It is possible to implement a fixed dictionary with the current release, but it requires a little more work and management by the user.fromcanonical_huffmanimportHuffmanCoding# First we need to create the fixed dictionaryhuff_fixed=HuffmanCoding()text="Lorem ipsum dolor sit amet."data=[ord(char)forcharintext]fixed_text="the quick brown fox jumped over the lazy dogs, THE QUICK BROWN FOX JUMPED OVER THE LAZY DOGS."fixed_data=[ord(char)forcharinfixed_text]huff_fixed.huff_dict.make_dictionary(fixed_data)# Then we can compress the data with the fixed dictionaryhuff_new=HuffmanCoding()huff_new.huff_dict.canonical_codes=huff_fixed.huff_dict.canonical_codeshuff_new.compress(data,fixed_dict=True)compressed_data=huff_new.encoded_text# For now, it is up to the user to save the encoded binary text to a file as they see fit.# The data should be much larger than the first example, since the fixed dictionary is not optimized for the dataprint('Fixed dict compressed data size: ',len(compressed_data)//8)
Package: canonicaljson
FeaturesEncodes objects and arrays asRFC 7159JSON.Sorts object keys so that you get the same result each time.Has no insignificant whitespace to make the output as small as possible.Escapes only the characters that must be escaped, U+0000 to U+0019 / U+0022 /
U+0056, to keep the output as small as possible.Uses the shortest escape sequence for each escaped character.Encodes the JSON as UTF-8.Can be configured to encode custom types unknown to the stdlib JSON encoder.Supports Python versions 3.7 and newer.InstallingpipinstallcanonicaljsonUsingTo encode an object into the canonicaljson:importcanonicaljsonassertcanonicaljson.encode_canonical_json({})==b'{}'There’s also an iterator version:importcanonicaljsonassertb''.join(canonicaljson.iterencode_canonical_json({}))==b'{}'The underlying JSON implementation can be chosen with the following:importjsonimportcanonicaljsoncanonicaljson.set_json_library(json)NoteBy default canonicaljson usessimplejsonunder the hood (except for PyPy,
which uses the standard library json module).A preserialisation hook allows you to encode objects which aren’t encodable by the
standard libraryJSONEncoder.importcanonicaljsonfromtypingimportDictclassCustomType:passdefcallback(c:CustomType)->Dict[str,str]:return{"Hello":"world!"}canonicaljson.register_preserialisation_callback(CustomType,callback)assertcanonicaljson.encode_canonical_json(CustomType())==b'{"Hello":"world!"}'
Package: canonicaljson-rs
Python package leveraging our Canonical JSON implementation in Rust.In order to validate content signatures of our data, Canonical JSON gives us a predictable JSON serialization.
And Rust allows us to reuse the same implementation between our server in Python (this package) and our diverse clients (Rust, Android/iOS, JavaScript).Usagepip install canonicaljson-rs>>>importcanonicaljson>>>>>>canonicaljson.dumps({"héo":42})'{"h\\u00e9o":42}'canonicaljson.dumps(obj: Any)->strcanonicaljson.dump(obj: Any, stream: IO)->strDevelopmentWe rely on a specific Python builder that automates everything around Rust bindings.pip install maturinIn order to install the package in the current environment:maturin developRun tests:pytestReleaseCreate a release on Github onhttps://github.com/mozilla-services/python-canonicaljson-rs/releases/newCreate a new tagvX.Y.Z(This tag will be created from the target when you publish this release.)Generate release notesPublish releaseSee Alsohttps://github.com/gibson042/canonicaljson-specThe code to build aserde_json::Valuefrom apyo3::PyObjectwas greatly inspired by Matthias Endler’shyperjsonOther specs:https://github.com/Kinto/kinto-signer/blob/6.1.0/kinto_signer/canonicaljson.pyhttps://searchfox.org/mozilla-central/rev/b2395478c/toolkit/modules/CanonicalJSON.jsmhttps://github.com/matrix-org/python-canonicaljsonLicenseMozilla Public License 2.0
Package: canonical-phone
Canonical PhonePurposeConvert given phone number into a string with hiphenated phone number with country code.
Default is assumed to be Indonesian number.Installationpipinstallcanonical-phone==0.0.10How to use?When country code is unknownfromcanonical_phone.phoneimportcanonical_numberphone_no=canonical_number(phone)# If invalid, returns Falseifnotphone_no:raiseException("invalid phone number")With country codefromcanonical_phone.phoneimportcanonical_numberphone_no=canonical_number(phone,has_country_code=True)# If invalid, returns Falseifnotphone_no:raiseException("invalid phone number")Input/Output Combinations[{"input":"62-8734878374","output":"62-8734878374",},{"input":"628734878374","output":"62-8734878374",},{"input":"8734878374","output":"62-8734878374",},{"input":"84-8734878374","output":"84-8734878374",},{"input":"91-8734878374","output":"91-8734878374",},{"input":"848734878374","output":"62-848734878374",},{"input":"848734878374","output":"84-8734878374","has_country_code":True,},{"input":"848734878374","output":"62-848734878374","has_country_code":False,},{"input":"91848734878374","output":"91-848734878374","has_country_code":True,}]Important NotesSupports only upto five digit country codes as of nowMobile number max length supported is 8-15 characters without country codePlease add any test cases you want to add to the input output list and create a PRReleasing Versions Guidehttp://anweshadas.in/how-to-upload-a-package-in-pypi-using-twine/
Package: canonicalwebteam.blog
Canonical blog extensionThis extension allows you to add a simple frontend section to your flask app. All the articles
are pulled fromCanonical's Wordpress back-endthrough the JSON API.This extension provides a blueprint with 3 routes:"/": that returns the list of articles"/": the article page"/feed": provides a RSS feed for the page.InstallationTo install this extension as a requirement in your project, you can use PIP;pip3installcanonicalwebteam.blogSee also the documentation forpip install.UsageLocal developmentFor local development, it's best to test this module with one of our website projects likeubuntu.com. For more information, followthis guide (internal only).TemplatesThe module expects HTML templates atblog/index.html,blog/article.html,blog/blog-card.html,blog/archives.html,blog/upcoming.htmlandblog/author.html.An example of these templates can be found athttps://github.com/canonical-websites/jp.ubuntu.com/tree/master/templates/blog.UsageIn your app you can then do the following:importflaskimporttalisker.requestsfromflask_reggieimportReggiefromcanonicalwebteam.blogimportBlogViews,build_blueprint,BlogAPIapp=flask.Flask(__name__)Reggie().init_app(app)session=talisker.requests.get_session()blog=build_blueprint(BlogViews(api=BlogAPI(session=session),))app.register_blueprint(blog,url_prefix="/blog")You can customise the blog through the following optional arguments:blog=build_blueprint(BlogViews(blog_title="Blog",blog_path="blog",tag_ids=[1,12,112],exclude_tags=[26,34],per_page=12,feed_description="The Ubuntu Blog Feed",api=BlogAPI(session=session,use_image_template=True,thumbnail_width=330,thumbnail_height=185,),))TestingAll tests can be run with./setup.py test.Regenerating FixturesAll API calls are caught withVCRand saved as fixtures in thefixturesdirectory. If the API updates, all fixtures can easily be updated by just removing thefixturesdirectory and rerunning the tests.To do this runrm -rf fixtures && ./setup.py test.
Package: canonicalwebteam.candid
Canonical Candid - Python packagecanonicalwebteam.candid provides authentication with Candid, a macaroon-based
authentication service.See:https://github.com/canonical/candidThis client only support the browser-redirect login protocol that
provides a mechanism for a user to authenticate with candid, and
subsequently discharge macaroons, by redirecting a web browser via
the candid login pages.How to installTo install this extension as a requirement in your project, you can use PIP:pipinstallcanonicalwebteam.candidSee also the documentation forpip install.DevelopmentThe package leveragespoetryfor dependency management.
Package: canonicalwebteam.discourse-docs
canonicalwebteam.discourse_docsFlask extension to integrate discourse content generated to docs to your website.InstallInstall the project with pip:pip install canonicalwebteam.discourse_docsYou can add the extension on your project as follows, replacing, at least,base_urlandindex_topic_idwith your own settings:importtalisker.requestsfromcanonicalwebteam.discourse_docsimportDiscourseDocs,DiscourseAPIapp=Flask("myapp")session=talisker.requests.get_session()discourse_docs=DiscourseDocs(parser=DocParser(api=DiscourseAPI(base_url="https://forum.example.com/",session=session),index_topic_id=321,url_prefix="/docs",),document_template="docs/document.html",url_prefix="/docs",)discourse_docs.init_app(app)Once this is added you will need to add the filedocument.htmlto your template folder.
Package: canonicalwebteam.django-views
Views for Django apps, primarily for use in Webteam Django apps.InstallationYou can install this module directly withpip install canonicalwebteam.django_views, or alternatively, includecanonicalwebteam.django_viewsinrequirements.txtfor your app.TemplateFinderTemplateFinderis an extension ofTemplateViewwhich attempts to
load the corresponding templates directly from URLs, without the need to
write a view for each URL.It can load HTML templates directly, or parse Markdown files that
contain a “wrapper_template” frontmatter key.UsageHere’s an example of how to make use ofTemplateFinderin your
Django app:# urls.pyfromdjango.conf.urlsimporturlfromcanonicalwebteam.django_viewsimportTemplateFinder# ...urlpatterns+=url(r"$^",TemplateFinder.as_view()),Template matchingWhen the app parses a URL, it will look for templates in the following
locations, in order:/parent/location/=>templates/parent/location.html/parent/location/=>templates/parent/location/index.html/parent/location/=>templates/parent/location.md/parent/location/=>templates/parent/location/index.mdMarkdown parsingIf theTemplateFinderencounters a Markdown file (ending.md) it
will look for the following keys inYAML
frontmatter:wrapper_templatemandatory: (e.g.:wrapper_template:/includes/markdown-wrapper.html) A path to an
HTML template within which to place the parsed markdown content. If
the path doesn’t have a leading slash (e.g. “templates/template.html”
or “../templates/template.html”), thenTemplateFinderwill search
for the template relative to the location of the Markdown file in
question. If the pathcontextoptional: (e.g.:context: {title: "Welcome", description: "A welcome page"}) A
dictionary of extra key / value pairs to pass through to the template
context.markdown_includesoptional: (e.g.:markdown_includes: {nav: }) A mapping of key names to template
paths pointing to Markdown files to include. Each template path will
be parsed, the resulting HTML will be passed in the template context,
under the relevant key.Here’s an example Markdown file:---
wrapper_template: "/includes/markdown-wrapper.html"
markdown_includes:
  nav: "includes/nav.md"
context:
  title: "Welcome"
  description: "A welcome page"
---

Welcome to my website.

## GitHub

I also have [a GitHub page](https://github.com/me).
Package: canonicalwebteam-docstring-extractor
docstring-extractorThis library allows parsing docstrings of an entire Python file. It usesastanddocstring-parser.The main difference between this library and docstring-parser is that this one is able to parse entire Python files.Installation:pip install docstring-extractorUsage>>>fromcanonicalwebteam.docstring_extractorimportget_docstrings>>>>>>withopen("example.py")asfile:...docstrings=get_docstrings(file)Imaging you have the following Python code:"""Example module.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmodtempor incididunt ut labore et dolore magna aliqua."""deftest_function():"""Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmodtempor incididunt ut labore et dolore magna aliqua. Ut enim ad minimveniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex eacommodo consequat. Duis aute irure dolor in reprehenderit in voluptatevelit esse cillum dolore eu fugiat nulla pariatur.Parameters:a (int): A decimal integerb (int): Another decimal integerReturns:str: A string containing "foo""""return"foo"The output of theget_docstringsfunction will be the following dict object:{'type':'Module','name':'example','line':0,'docstring':<docstring_parser.common.Docstringat0x7f06adee7a00>,'docstring_text':'Example module.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\ntempor incididunt ut labore et dolore magna aliqua.','content':[{'type':'Function','name':'test_function','line':9,'docstring':<docstring_parser.common.Docstringat0x7f06adef7490>,'docstring_text':'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim\nveniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\ncommodo consequat. Duis aute irure dolor in reprehenderit in voluptate\nvelit esse cillum dolore eu fugiat nulla pariatur.\n\nParameters:\na (int): A decimal integer\nb (int): Another decimal integer\n\nReturns:\nstr: A string containing "foo"','content':[]}]}You can see the different properties of the Docstring objecthere, as an example if you are interested in obtaining the return type and return description of the first function:>>>docstrings["content"][0]["docstring"].returns.type_name'str'>>>docstrings["content"][0]["docstring"].returns.description'A string containing "foo"'