Saravanan666/pypi-org huggingface dataset:
Package: tgext.minify
About tgext.minifytgext.minify is a Turbogears 2 middleware that automatically minifies your javascript
and CSS and cache it. It’s able to obfuscate your js too.
CSS minifier based on rCSSmin by André Malo.
JS minifier/obfuscator based onSlimItby Ruslan Spivak
The middleware is based ontgext.scssby Alessandro MolinaInstallingtgext.scss can be installed both from pypi or from bitbucket:easy_install tgext.minifyshould just work for most of the usersEnabling tgext.minifyIf tgext.pluggable is available enabling tgext.minify is just a matter of appending to yourconfig/app_cfg.py:from tgext.pluggable import plug
plug(base_config, 'tgext.minify')Otherwise manually using tgext.minify is really simple, you edit yourconfig/middeware.pyand just after
the#Wrap your base TurboGears 2 application with custom middleware herecomment wrapappwithMinifyMiddleware:from tgext.minify import MinifyMiddleware

make_base_app = base_config.setup_tg_wsgi_app(load_environment)

def make_app(global_conf, full_stack=True, **app_conf):
    app = make_base_app(global_conf, full_stack=True, **app_conf)

    # Wrap your base TurboGears 2 application with custom middleware here
    app = MinifyMiddleware(app)

    return appNow you just have to put your beautiful .css and .js files insidepublic/and they will be served as minified.JS obfuscationIf you need to obfuscate your javascript, just addmangle_js = trueto yourdevelopment.ini.
If you want to obfuscate also the global scope, addmangle_js_toplevel = true. Keep in mind that
if you obfuscate your js, you have to join js files that depends on each other, or the namespace will
be messed up.Performance boostHere is the report of a benchmark made on paster serving bootstrap.css with and without the middleware
and then bootstrap.min.js already minified (without using the middleware):$ /usr/sbin/ab -n 1000 http://localhost:8080/css/bootstrap.css
Requests per second:    1135.50 [#/sec] (mean)

$ /usr/sbin/ab -n 1000 http://localhost:8080/css/bootstrap.css
Requests per second:    714.99 [#/sec] (mean)

$ /usr/sbin/ab -n 1000 http://localhost:8080/css/bootstrap.min.css
Requests per second:    806.26 [#/sec] (mean)In these case serving the unminified css using tgext.minify is even faster
than directly serving the same css file as it is served from memory
(due to caching performed by tgext.minify).
Package: tgext.mobilemiddleware
About Mobile MiddlewareMobile Middleware is a middleware for WSGI applications.Thought to be used on TurboGears 2 applications it detects mobile browser and provides a way
to detect and react to them. Detection expression can be customized and action can
change from plain detection to exposing a specific custom template for mobile requestsYou will be able to see if your request is coming from a mobile browser with:from tg import request
request.is_mobileInstallingtgext.mobilemiddleware can be installed both from pypi or from bitbucket:easy_install tgext.mobilemiddlewareshould just work for most of the usersEnabling Mobile Agents DetectionIn your applicationconfig/middleware.pyimportMobileMiddleware:from tgext.mobilemiddleware import MobileMiddlewareChange yourmake_appmethod:app = make_base_app(global_conf, full_stack=True, **app_conf)
return MobileMiddleware(app, app_conf)Exposing Mobile Templatestgext.mobilemiddlewareimplements a@expose_mobiledecorator that works like@exposeTurboGears2 decorator which can be used to specify which template to expose for mobile requests.This will work by switching the template before rendering the view if the request
is detected to be from a mobile browser.@expose_mobilesupports the same template naming convention that @expose uses
and can accept any rendering engine that has been registered in TurboGears
by specifying it asengine:module.template_nameExamples:@expose('app.templates.index')
@expose_mobile('app.templates.mobile.index')
def index(self, *args, **kw):
    return dict()Customizing User Agents DetectionIf you want to quickly customize the regular expression used to detect the mobile browser you can definemobile.agentsconfiguration variable in your application config file and set it to the regular expression that you want to use.For more complex customizations, you may create your own subclass ofDetectMobileBrowser,
or callable object and supply it as an argument toMobileMiddleware, like:return MobileMiddleware(app, app_conf, mobile_browser_detector=YourClass)DetectMobileBrowserbehaviour can be changed by any subclass by overridding theDetectMobileBrowser.perform_detectionmethod.
If user has defined a custom regular expression it will be available inside theperform_detectionmethod asself.custom_mobile_re
Package: tgext.odt
About tgextodttgextodt is a Pluggable application for TurboGears2 that allows the rendering of .odt (openoffice/libreoffice) documents as an output templates.Installingtgextodt can be installed both from pypi or from bitbucket:pip install tgextodtshould just work for most of the usersPlugging tgextodtIn your applicationconfig/app_cfg.pyimportplug, then at theend of the filecall plug with tgextodt:from tgext.pluggable import plug
plug(base_config, 'tgextodt')UsageTo use an odt template you have to declare the type in your controller as below:@expose('odt:example.templates.about', content_type='application/vnd.oasis.opendocument.text')
def about(self):
    response.headerlist.append(('Content-Disposition', 'attachment;filename=filename.odt'))
    return dict(hello='Hello World')obviously in yourexampleapplication in the folderexample/templatesyou should provide a templated named about.odt in wich you have defined the variable fieldpy3o.document.hello.To define a variable field in libreoffice you can dig more information onhttps://help.libreoffice.org/Writer/Variablesbasically from the menu Insert -> Fields -> Other -> VariablesFor more complex features, like for loops and more detailed reporting stuff, you want to read the documentation of the py3o library itselfhttp://py3otemplate.readthedocs.org/Now you can directly download your output from/aboutor/about.odt
Package: tgext.scss
About tgext.scssSCSSis a cool and useful extension to CSS,
but it always required some effort to be used and even
specific production environment configurations for some systems.tgext.scss has born to make life easier forTurboGears2developers,
it will rely on an internal minimal SCSS compiler
(based onZeta-LibrarySCSS parser)
to serve all the files in your public directory
that end with.scssastext/cssconverting them and minifying them.Installingtgext.scss can be installed both from pypi or from bitbucket:easy_install tgext.scssshould just work for most of the usersEnabling tgext.scssIf tgext.pluggable is available enabling tgext.scss is just a matter of appending to yourconfig/app_cfg.py:from tgext.pluggable import plug
plug(base_config, 'tgext.scss')Otherwise manually using tgext.scss is really simple, you edit yourconfig/middeware.pyand just after
the#Wrap your base TurboGears 2 application with custom middleware herecomment wrapappwithSCSSMiddleware:from tgext.scss import SCSSMiddleware

make_base_app = base_config.setup_tg_wsgi_app(load_environment)

def make_app(global_conf, full_stack=True, **app_conf):
    app = make_base_app(global_conf, full_stack=True, **app_conf)

    # Wrap your base TurboGears 2 application with custom middleware here
    app = SCSSMiddleware(app)

    return appNow you just have to put your .scss file insidepublic/cssand they will be served as CSS.@Import Supporttgext.scss provides minimal support for @import command. The required syntax is in the form:@import url('/css/file.scss');The specified path is relative to your project public files directory.Nested imports are not implemented right now, this means that imported files cannot import another scssHow much it will slow me down?Actually as tgext.scss uses aggressive caching it won’t you slow down at all,
indeed it might even be able to serve you CSS files even faster.Here is the report of a benchmark (absolutely not reliable as every other benchmark)
made on paster serving the same CSS file or SCSS:$ /usr/sbin/ab -n 1000 http://localhost:8080/css/style.css
Requests per second:    961.26 [#/sec] (mean)

$ /usr/sbin/ab -n 1000 http://localhost:8080/css/style.scss
Requests per second:    1200.34 [#/sec] (mean)In these case SCSS is even faster than directly serving the same css file as
it is served from memory (due to caching performed by tgext.scss)
and is also minified resulting in less bandwith usage.Off course this means that tgext.scss will require a bit more memory than serving
your css files alone, but as css files are usually small this amount is trascurable.
Package: tgext.utils
About tgext.utilstgext.utils is a collection of utilities for the TurboGears2 web framework.Installingtgext.utils can be installed from pypi:pip install tgext.utilsshould just work for most of the users.CSRF Protectiontgext.utils.csrfprovides two decorators@csrf_tokenand@csrf_protectwhich
generate a CSRF token for inclusion in a form and check that the token is valid.The user must apply@csrf_tokendecorator to the action that exposes the form,
and put an<inputtype="hidden">into the form with arequest.csrf_tokenas
the value and_csrf_tokenas name:@csrf_token@expose()defform(self):return'''
    <form method="POST" action="/post_form">
        <input type="hidden" name="_csrf_token" value="%s">
    </form>'''%request.csrf_tokenThe action that receives the form must have@csrf_protectdecorator,
no particular action or check is required on this action:@csrf_protect@expose()defpost_form(self,**kwargs):return'OK!'MetaTagstgext.utils.meta.metatagsprovides a convenient way to generate common meta tags
for a web page.Inlib/helpers.pyadd:fromtgext.utils.metaimportmetatagsThen in your pages:${h.metatags(title="pagetitle",description="Page Description",image="http://url/myimage.png")}Slugtgext.utils.slugprovides a way to generate slug for your pageto generate a slug use:fromtgext.utils.slugimportslugifymyslug=slugify(model_id,string_to_be_inserted_in_the_url)to get the id from a slug use:fromtgext.utils.slugimportslug2entityidslug2entityid(myslug)Storagetgext.utils.storageis a tool for storing files into /public dir in separated folders.fromtgext.utils.storageimportstorefilename=store(ufile)# ufile is an instance of cgi.FieldStoragefile is stored inside /public/storage/${uuid1} folder thus also accessible using internal tg file serving.
Package: tgext.webassets
About tgext.webassetstgext.webassets is a TurboGears2 extension for assets management
based onWebAssets.Installingtgext.webassets can be installed from pypi:pip install tgext.webassetsshould just work for most of the users.UsageTo enable tgext.webassets put inside your applicationconfig/app_cfg.pythe following:from tgext import webassets

webassets.plugme(base_config, bundles={
    'js_all': webassets.Bundle('javascript/jquery.js', 'javascript/bootstrap.min.js',
                               filters='rjsmin', output='assets/js_all.js')
})or you can usetgext.pluggablewhen available:from tgext.pluggable import plug
from tgext.webassets import Bundle

plug(base_config, 'tgext.webassets', bundles={
    'js_all': Bundle('javascript/jquery.js', 'javascript/bootstrap.min.js',
                     filters='rjsmin', output='assets/js_all.js')
})By defaulttgext.webassetswill load and save assets inside the turbogearsstatic_filespath. Which is usually thepublicdirectory inside your
application.NoteDue totgext.webassetswriting files to the same place where it loads them,
it is suggested you add a subdirectory to theoutputoption of your bundles,
so that the resulting files do not mix with the source files.The webassets environment will then be available astg.app_globals.webassets, so you can
use it inside your templates to load the assets:<script py:for="asset_url in g.webassets.js_all.urls()" src="$asset_url"></script>Each registered bundle will be available as a property of theg.webassetsobject
inside templates.Bundlesŧgext.webassetsaccepts the bundles inside thebundlesdictionary. Each entry
can be aBundleinstance or awebassets loaderin case you want to load bundles from a configuration file.ConfiguringOptions available inWebAssets Environmentare also available in tgext.webassets, pass them as arguments to theplug(inside theoptionsdictionary when usingtgext.webassets.plugme) or provide the through AppConfig
or.inifile withwebassets.namespace.Some have values that are inherited from your project configuration if not specified:debug: If webassets is running in debug mode or not, by default isFalse.base_dir: The directory assets will be located. By default is your projectstatic_filesdirectory.base_url: The url static assets are served, by default/. Use this option to serve them from a CDN.cache: If we should use webassets cache (if boolean), or override default path to cache directory
by default assets are cached inside the.webassets-cachedirectory insidebase_dir.Builtin Filterstgext.webassetscomes with builtin therjsminandcssminfilter,
allwebassets filterswork if the required tools are available.
Package: tg-file-id
tg_file_idParse and construct Telegramfile_ids andunique_file_ids.
Even generate aunique_file_idfrom afile_id.Examples belowInstallParsefile_idsParsefile_unique_idsConvertfile_ids tofile_unique_idsInstallpipinstalltg-file-idParsefile_idsfromtg_file_id.file_idimportFileIdfile_id=FileId.from_file_id('CAACAgIAAxkBAAIEol9yQhBqFnT4HXldAh31a-hYXuDIAAIECwACAoujAAFFn1sl9AABHbkbBA')Now thefile_idvariable is an object like this:DocumentFileId(file_id='CAACAgIAAxkBAAIEol9yQhBqFnT4HXldAh31a-hYXuDIAAIECwACAoujAAFFn1sl9AABHbkbBA',type_id=8,type_generic='document',type_detailed='sticker',dc_id=2,id=46033261910035204,access_hash=-5107925353769492667,version=4,sub_version=27,)Parsefile_unique_idsfromtg_file_id.file_unique_idimportFileUniqueIdunique_id=FileUniqueId.from_unique_id('AgADBAsAAgKLowAB')Now theunique_idvariable is an object like this:FileUniqueId(unique_id='AgADBAsAAgKLowAB',type_id=2,id=46033261910035204)Convertfile_ids tofile_unique_idsfromtg_file_id.file_unique_idimportFileUniqueIdunique_id=FileUniqueId.from_file_id('CAACAgIAAxkBAAIEol9yQhBqFnT4HXldAh31a-hYXuDIAAIECwACAoujAAFFn1sl9AABHbkbBA')calculated_file_unique_id=unique_id.to_unique_id()Nowcalculated_file_unique_idis'AgADBAsAAgKLowAB'
Package: tggl
Tggl Python ClientInstallIntall the package using the package manager of your choice:pip install tgglQuick StartfromtgglimportTgglClientclient=TgglClient('<Your API key>')flags=client.eval_context({'user_id':123,'email':'foo@gmail.com','plan':'PRO'})# On/Off flagsif(flags.is_active('feature_1')):print('Feature 1 is active')# A/B testsif(flags.get('feature_2')=='Variation A'):print('Should display variation A to user')# A/B test with default valueif(flags.get('feature_2','Variation A')=='Variation B'):print('Should display variation B to user')
Package: tg-hammer
# tg-hammer[![Build Status](https://travis-ci.org/thorgate/tg-hammer.svg?branch=master)](https://travis-ci.org/thorgate/tg-hammer)
[![PyPI version](https://badge.fury.io/py/tg-hammer.svg)](https://badge.fury.io/py/tg-hammer)Helpers for fabric based deployments.## QuickstartInstall tg-hammer:pip install tg-hammer## FeaturesSee the documentation for detailed information.https://tg-hammer.readthedocs.org### VCSHammer provides unified helper api for both git and Mercurial
based projects. It can automatically detect which version control
system to use based on the current project (by inspecting project_root).### ServicesHammer contains management helpers for the following unix service daemon utilities:upstartsystemdsupervisor## TestingHammer includes functional tests that are executed inside Docker containers. The filerun-tests.shexecutes threedocker-composecommands that first brings up a slave server,
then a master server which executes the tests during building, and brings both of these down
after execution. The master acts as the developer machine and the slave as the server
where deployments are run on.To run the tests manually, first comment out the line:py.testand uncomment the line# tail -f /dev/nullinsidedocker-entrypoint-master.sh. This will keep both the master and slave running when
you executedocker-compose up –buildNow you can enter abashshell inside the master by executing:docker exec -it tghammer_master_1 /bin/bashAt this point you can simply executepy.testto run the tests.Either method of running the tests will print tons of output and will (hopefully) result in all tests
passing. Sadly it is not possible to usepy.testcapturing to reduce the amount of spam because
this program is not compatible withfabric’s internal capturing logic.
Package: tghelper
Useful tools to work with TigerGraph in PythonDescriptionIt consists of one module:tghelper: helper functions to work with TigerGraph and pyTigerGraphWith two main functions:execute_gsql: Execute a gsql statement that is stored in a fileupload_job: Uses multiprocessing to upload the file and then executes the loading job for the fileExamplesimportpyTigerGraphfromtghelperimportTgHelperimportgetpassmy_pwd=getpass.getpass()tg_conn=pyTigerGraph.TigerGraphConnection(host="http://127.0.0.1",graphname="MyGraph",username="usr_name",password=my_pwd)tgh=TgHelper(conn=tg_conn)tgh.execute_gsql("my_gsql_statement.gsql")tgh.upload_job(source_file="my_data.csv",job="my_loading_job",job_filename="job_filename")InstallationNormal installationpipinstalltghelperDevelopment installationgitclonehttps://github.com/louisza/tghelper.gitcdtghelper
pipinstall--editable.pypi Build reminder (for the developers)python3setup.pysdistbdist_wheel
Package: tg_interface
Feature===============tg_interface is a interface javascript library wrapper and ajax helper forTurboGears web designers.Available widgets====================* tg_interface (turbogears interface plugin)Install==============Use setuptools to install::$easy_install tg_interfaceUsage==============tg_interface~~~~~~~~~include in config/app.cfg::tg.include_widgets = ['tg_interface.tg_interface']Reference============- tg_interface http://interface.eyecon.ro/
Package: tg-ip-lookup
Lookup an IP address to find out which public cloud it originates fromThis repository contains python3 code to find out which public cloud an IP address originates from.RequirementsPython3 (3.11)MaxMind license key (forGeoLite2 ASNdatabase).This database is free subject to license restrictions by MaxMind. Sign uphere.Supported CloudsAmazon Web Services (AWS)Google Cloud Platform (GCP)Microsoft AzureOracle Cloud Infrastructure (OCI)HetznerDigitalOceanLinodeTencentOVHIBM CloudVultrScalewayFly.ioStarlink (yes ok, not a cloud but it is up in the clouds right?)How it worksFor AWS, GCP, Azure and OCI this looks up the IPs using the publicly published IP ranges by these providers.For the other providers it uses the MaxMind ASN database to lookup IP information.Internally this is using theipaddressmodule in python to do a search through the various CIDR blocks. In future this could be improved if the need arises.Setuppip install tg_ip_lookupPrepare the database, executepython -c "exec(\"import tg_ip_lookup\ntg_ip_lookup.cloudlookup.loadCloudProviderData.main(\'*MaxMind License Key*\')\")"Try an IP lookuppython -c "exec(\"import tg_ip_lookup\ntg_ip_lookup.main(\'XXX.XXX.XXX.XXX\')\")"
Package: tgju-crawl
به کمک این ماژول می‌توانید تاریخچه قیمت‌های روزانه موجود در سایت اطلاع‌رسانی طلا، سکه و ارز را دریافت کنید که شامل اطلاعات 240 دارایی متفاوت از جمله طلا،   سکه، ارز، حوزه نفت و انرژی، برخی کالاهای جهانی و مهمترین رمز ارزها است که از جمله ویژگی‌های مهم این ماژول می‌توان به موارد زیر اشاره کرد:امکان دسترسی به تاریخچه قیمت ها در سایت اطلاع رسانی طلا، سکه، ارز   <---خروجی سازگار با دیتافریم پانداز و قابلیت فیلترینگ زمانی مجدد بر اساس تاریخ شمسی    <---قابلیت ارائه تاریخ شمسی، میلادی و نام ایام هفته برای داده‌های روزانه    <---نصب ماژولpython3-mpipinstalltgju_crawlفراخوانی ماژولimporttgju_crawlastgمشاهده نمادهای موجود در ماژول: دیتافریم نمادهاtg.get_df_of_symbols()دریافت تاریخچه قیمت یک نماد: دریافت تاریخچه قیمتیtg.get_tgju_data(symbol='حباب نیم سکه')
Package: tglib
Asynchronous python implementation of the Telegram Bot API7.1PrerequisitesYou require a good python knowledge with theasyncio moduleand a Telegram Bot API token, you can get it via@BotFather.DependenciesPython >= 3.8aiohttpOptionalujson&certifiInstallation$pipinstalltglibKeep it updated$pipinstall-UtglibReply MarkupsInlineKeyboardMarkupandReplyKeyboardMarkuphave the method "add", so you can create new buttons after the object has been initialized.markup=ReplyKeyboardMarkup()markup.add(KeyboardButton('x'),KeyboardButton('y'))# All the buttons added with this method will be in# the same row, you can change the row width after the# object initialization using the property setter 'row_width'.markup.row_width=4# The keyboard will be rearranged with 4 buttons each row.NotesWebhook has not been implemented yet.Usage#!/bin/python3fromtglibimport(Client,NextManager,TelegramError)# Import all the types.fromtglib.typesimport*# Create a bot instance.bot=Client('<your_token>')# Add some rules for incoming updates. Managers# check rules in the same order they were added.@bot.manage_message(lambdamessage:message.text=='/start')asyncdeffoo(message:Message):try:awaitbot.send_message(message.chat.id,'Welcome!')except(TimeoutError,TelegramError):pass# Two errors can be raised in requests:# - TimeoutError if a response#   is not returned in 5 minutes.# - TelegramError if a response is#   returned but got a bad status code.else:returnNextManager()# Returning a NextManager instance, you will pass# the update to the following manager of the same kind.# You can also add rules with the# method 'add_rule' of the managers.defchecker(message:Message):returnmessage.text=='/help'asyncdefbar(message:Message):awaitbot.send_message(message.chat.id,'Need help?')bot.message_manager.add_rule(checker,bar)# Calling the method 'long_polling',# the bot starts receiving updates by# the telegram server and process them.importasyncioif__name__=='__main__':asyncio.run(bot.long_polling())
Package: tglog
Useful functions to log efficiently into a log.txt file and send you logs by Telegram.Using this logger will :Create alog.txtfile and append it new errors, with date and time of happening ;Send you every info or error via Telegram.To install, typepython3 -m pip install tglog, or try withpyinstead ofpython3if you get any error.You need your telegram chat_id, usually a chain of integers and the token of the telegram bot you want to receive logs from.If you don't know your telegram chat_id, just send/my_idto telegram bot@get_id_bot.If you haven't created any telegram bot, just send/newbotto@BotFather.How to use :Initialization :import tglog

my_chat_id = "12345"            # Your telegram chat_id
my_bot_token = "token123"       # The token of the telegram bot you want to receive logs from

# Initialize your logger :

tl = tglog.logger(my_chat_id, my_bot_token)Use any of those functions in your code :Useful for debugging ; Telegram bot won't send notification :Receive message when checkpoint reached :tl.debug("info for debugging")Useful for logging some infosReceive some infos :tl.info("info to be logged")Useful for logging errorsReceive traceback of errors :tl.error(traceback.format_exc())