Saravanan666/pypi-org huggingface dataset:
Package: ugctools
Ugc tools一个将mardown转换成为png的工具，特别适合于小红书发贴，也可定制为支持其他自媒体。"一觉醒来"系列头部都在一周之内，从零涨粉到超过10万。这个系列的特点是对时效要求高，又要求每个贴子间格式统一，因此，多数都在使用类似工具来创作和发布。使用说明ugctools首先将markdown创作的内容与模板/主题结合，生成html文档，再通过chrome/weasyprint将其转换成为pdf，最后再转换成可用于小红书发贴的图片。ugctools设计为支持多个应用。你可以为每个应用配置多个主题。每个主题由一系列的html模板和样式来决定。将文案中固定部分提取为模板(html)，创作内容部分使用markdown。<htmllang="en"><head><metacharset="UTF-8"><style>{css}</style></head><body><divid="rb"><divid="header"><divid="date_extra"><divid="date">{date:YYYY/MM/DD ddd}</div><divid="extra">{extra}</div></div><divid="title">一觉醒来财经圈发生了什么</div><divid="subtitle"><divid="author">By {author}</div></div></div><divid="content">{content}</div></div></body></html>content部分即为我们要创作的内容，格式为markdown。生成最终图像前，工具将其转化为html，再插入到{content}
所标识的位置处。段落和分页在markdown中，连续两个换行符才会引起一个新的段落。单个换行符并不会引起新的段落（但有些解析器，比如GMF会将单个换行符替换为一个，这会导致一个硬换行，但前后两行仍然是一个段落，即一个html的标签）。使用来进行分页，这是我们对markdown语法的扩展。比如下面的markdown:this is page 1
<!-- page-->
this is page2将生成两张图片。每一页都可以使用自己的模板。比如，第0页的模板名为page-0.tpl,第一页的模板为page-1.tpl。如果对应的模板不存在，则使用default.tpl。语法author可以在cfg.json中定义author，然后可以将其插入到模板中。date可以在模板中使用 {date: formatDate}宏。系统将使用当前日期（也可通过命令行传入其它日期）。extra在模板中，允许插入一个自定义字段。该字段将通过命令行传入。Usage通过命令行:ugc news markdown_file --extra "早间60秒" --serve这将会生成png图片，并可通过http://ip:1086来预览。支持的选项有:
* --date '2023-03-31'
* --serve: 这将开启一个http服务器，供预览生成的图片
* --extra: 向模板提供额外的信息markdown_file只传文件名，不传路径。markdown_file的搜索路径在 cfg.json中指定。配置配置和模板文件在~/.ugc/redbook/news下。首次运行后，将自动生成该目录及示例文件。自定义样式样式中提供了 rb, header, title, date_extra, subtitle, re等带id的元素可供定制。预定义样式支持对图片进行居中、左浮动对齐和右浮动对齐。下面的示例演示了将图片缩放为屏幕宽度的1/4大小，并左浮动：然而，各大AI实验室为了开发和应用更加强大的人工智能，最近几个月已经陷入了“失控”的竞赛，甚至连AI系统的创始人也并不能完全理解、预测和有效控制其风险，相应的计划和管理工作没有跟上。

![](https://t7.baidu.com/it/u=1362366007,2277133945&fm=193&f=GIF){: .img-left-25 }

《每日经济新闻》注意到，在签名名单里的尾部，赫然出现了阿尔特曼的名字。然而，由于签名是公开征集，尚无法证明是否是阿尔特曼本人签署，其本人亦未回应。签名中OpenAI最后一个字母为小写，或有故意之嫌疑。注意这里无论是左浮动还是右浮动，图片都要插入在文字段前面。注意{: .img-left-25 }将向生成的标签中插入一个 class = .img-left-25的样式。注意{}必须紧接()。居中对齐：然而，各大AI实验室为了开发和应用更加强大的人工智能，最近几个月已经陷入了“失控”的竞赛，甚至连AI系统的创始人也并不能完全理解、预测和有效控制其风险，相应的计划和管理工作没有跟上。

![](https://t7.baidu.com/it/u=1362366007,2277133945&fm=193&f=GIF){: .img-center-25 }

《每日经济新闻》注意到，在签名名单里的尾部，赫然出现了阿尔特曼的名字。然而，由于签名是公开征集，尚无法证明是否是阿尔特曼本人签署，其本人亦未回应。签名中OpenAI最后一个字母为小写，或有故意之嫌疑。样式中25表明图片宽度占屏幕的1/4， 50意味着50%, 75%和100%以此类推。安装ugctools依赖来chrome来生成pdf文件。如果系统中不能安装chrome（比如一些Linux服务器），则需要安装weasyprint:推荐通过conda安装weasyprint:condainstall-cconda-forgeweasyprint然后安装：pip install ugctools如果指定的字体在机器上不存在，则需要提前安装字体。比如：cp fonts/*ttf /usr/local/share/fonts/
sudo fc-cache -fv推荐优先使用chrome，生成的图像还原度高。
Package: uge2slurm
uge2slurmGrid Engine to Slurm command converterInstallationuge2slurm provides conversion fromqsubcommand in UGE/SGE to Slurm'ssbatchcommand.pip install uge2slurmAfter installation, the following commands are available.uge2slurm [{qsub}]qsub <qsub args>The following commands are installed as a part of uge2slurm but current version
does not support command conversions.qacctqalterqconfqdelqholdqhostqloginqmakeqmodqmonqpingqquotaqralterqrdelqresubqrlsqrshqrstatqrsubqselectqshqstatCommand usageThese options are commonly available for all subcommands.-?/--helpShow help message and exit.--versionShow version info and exit.--ignore-coloringDisable colored output.--verbose [{"critical"|"fatal","error","warn"|"warning","info","debug",int}]Set verbosity in Python logging level. Default is "warning". If only--verboseflag is given, level is set to info.uge2slurmList Grid Engine and Slurm commands' existence and exit.qsubConvertqsubcommand tosbatchcommand and execute.The following options can be specified besidesqsubarguments.-n/--dry-runPrint converted Slurm command and exit.-y/--non-interactiveBy default, uge2slurm shows a converted command line and get confirmation before
the execution when a TTY is allocated. This option disables the preview
and the command will be executed immediately.--memory resource [...]Specify which resource value should be mapped into--mem-per-cpuoption.
If multiple values are specified, the first valid value will be used.--cpus parallel_env [...]Specify which parallel_environment should be mapped into--cpus-per-taskoption.
If multiple values are specified, the first valid value will be used.Note that range values are not supported and its minimum value will be used as
the number of cpus.--partition resource=partition [...]Specify which resource name should be mapped into partition (queue) via--partitionoption. Resource-partition pairs must be specified by '='
separated strings.The partition mapping is solved by the following order:use relations specified by--partitionoption when the partition name is
exactly matched.split partition name by punctuations except '-' and '_' then try exact match
on the prefix and resource names.try forward matching on partition names and resource names.Examples:% sinfo --format "%P"
PARTITION
gpu.q
gpu_intr.q

% uge2slurm qsub -n -l gpu_in test.sh
sbatch
	 --partition gpu_intr.q

% uge2slurm qsub -n -l gp test.sh
ERROR: Resource specification "gp" matches multiple partitions.
WARNING: 	gp -> gpu.q, gpu_intr.q
WARNING: Try to add implicit mapping option like `--partition gp=gpu.q`.
CRITICAL: Error: failed to map resource into partition.

% uge2slurm qsub -n -l gpu test.sh
sbatch
	 --partition gpu.q

% uge2slurm qsub -n --partition gpu=gpu_intr -l gpu test.sh
sbatch
    --partition gpu_intr
Package: ugecko
uGeckoPython library for use with TCPGecko. Requires kernel exploit to use.(WARNING: Tested on Python 3.8 to 3.9).You can find examples in the folderexamples.CreditsNWPlayer123, wj44, and wiiudevforpyGeckoChadderz and Marionumber1forTCPGecko codehandlerBullyWiiPlazafor the current version ofTCPGeckoVCodingfor this modified version ofpyGecko, specially designed for theTCPGecko versionofBullyWiiPlaza.
Package: uge-drmaa2
Copyright 2008-2022 Altair Engineering Inc.
Licensed 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 athttp://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.UGE DRMAA v2 Python APIPrerequisitesUGE DRMAA2 requires recent versions of the following software:UGE (8.6.8 or above)Python (v2.7.5 or later in 2.7 series, or in any 3.x series)Setuptools (0.9.8 or later; for egg installation)Nose (1.3.7 or later; for testing)Sphinx (1.1.3 or later; for generating documentation)Standard development tools (make)Python wheel module (0.32.3 or later; for generating wheel package)enum34 module for IntEnum (remove enum module)The software versions listed above were used for API development and
testing, on CentOS 7.2 (64-bit).Build/PackageIn the top level directory run:$makeclean$makeThis command should create installable egg and wheel packages, as well
as generate documentation and copy it into thedistdirectory.Basic API UsageFor simple testing, without installing UGE DRMAA2 egg or wheel package,
do the following:Setup SGE environment:$source$SGE_ROOT/$SGE_CELL/common/settings.shSetup PYTHONPATH environment variable to point to the top level
directory:$exportPYTHONPATH=<UGE_DRMAA2_PYTHON_ROOT>This step is not needed if UGE DRMAA2 egg or wheel package is installed.At this point you can import and use the drmaa2 module:$python>>>importdrmaa2>>>print(drmaa2.get_drmaa_name())UnivaGridEngineDrmaaV2Note that there are a number of API usage examples located under theexamplesdirectory.Running Test SuiteSetup SGE environment:$source$SGE_ROOT/$SGE_CELL/common/settings.shIn the top level directory run:$maketest
Package: ugentbiblio
Ghent University Academic Bibliographycontains all the scientific publications byUGentResearchers. TheAPIis public and pretty straight forward.To use the API in Python this wrapper is available. Instead of returning JSON, it returns dictionaries, and provides methods for querying the API, instead of having to do the formatting yourself.Installationpip install ugentbiblioUsageConsult thereadthedocs.TestingTesting is done with pytest, install it together with some other dependenciespip install -r requirements_dev.txtTo run all the tests, runpy.testTo run all the tests, except the slow ones, runpy.test -k-slow
Package: ugent-food
ugent-foodCommand-line tool to get the current menu for Ghent University restaurants.This application was made usingZeus WPI'
sHydra API.InstallationIt's recommended to install the tool usingpipxto allow running the
command from anywhere on your PC, without having to invoke it usingpython3 -m ugent_food.$pipxinstallugent-foodIf you don't want to usepipx, it can also be installed usingpip:$pip3install--userugent-foodNote:Don't install this in a Virtual Environment, as you won't be able to run it from anywhere else.Next, you can add an alias to your.bashrcor.zshrcfor your own convenience:# If you installed using pipx$echo'alias food="ugent-food"'>>~/.bashrc
$echo'alias food="ugent-food"'>>~/.zshrc# If you installed using pip$echo'alias food="python3 -m ugent_food"'>>~/.bashrc
$echo'alias food="python3 -m ugent_food"'>>~/.zshrcYou can now simply usefoodto run the tool.UsageTo keep the examples short, they usefoodinstead ofpython3 -m ugent_foodto invoke the tool.MenusTo get the menu for a given day, use themenucommand. By default, not passing any arguments will fetch today's
menu:$foodFor convenience, passing this command isoptional. You can immediately pass a day (or subcommand) instead of having
to explicitly add this as well. The above line is equivalent to$foodmenuArgumentsTo fetch the menu for a specific day, an extra argument can be passed. This can either be a weekday, an offset (relative
to today), or a day inDD/MM-format:$foodmonday
$foodtomorrow
$food21/09ConfigurationThe tool has a couple of settings that you can configure using thesetsubcommand:$foodconfigsetskip_weekendstrueYou can list the current settings withconfig ls:$foodconfiglsAvailable settingsNote thatbooleanarguments can be supplied as any of[true, false, t, f, 1, 0].NameDescriptionType (choices)DefaulthiddenA list of meal kinds that should be hidden when fetching menus. This can be useful for vegetarians and vegans who don't care about the meat dishes.List[String] ("fish", "meat", "soup", "vegan", "vegetarian")[]languageThe language used to fetch the menus in.String ("en" 🇬🇧 , "nl" 🇧🇪/🇳🇱)"en"skip_weekendsWhether to automatically skip weekends when fetching menus without an explicit day argument. This defaults to true because the restaurants aren't usually open during weekends. For example: using the tool on a Saturday will show the menu for the coming Monday.BooleanTrue
Package: uge-pycl
Copyright 2016-2022 Altair Engineering Inc.
Licensed 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 athttp://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.UGE Python Configuration LibraryPrerequisitesUGE PyCL requires recent versions of the following software:UGE (8.3.1p9, 8.4.0, or later)Python (v2.7.5 or later in v2.7 series)Setuptools (0.9.8 or later; for egg installation)Nose (1.3.7 or later; for testing)Sphinx (1.1.3 or later; for generating documentation)Standard development tools (make)The software versions listed above were used for prototype development
and testing, on CentOS 7.2 (64-bit). It is likely that any recent
version of Python (such as those that come with current linux
distributions) should work. UGE versions 8.3.1p9 or later or 8.4.0 and
later will work with the Configuration API. Minor modifications to the
code that checks versions will have to be made to support versions
greater than 8.4.0.BuildIn the top level directory run:$makeThe above command will create UGE PyCL egg package in thedistdirectory, which can be installed using theeasy_installcommand. It
will also runsphinx-buildcommand and generate HTML documentation
in thedist/doc/htmldirectory.Basic API UsageFor simple testing, without installing UGE PyCL egg package, do the
following:Setup PYTHONPATH environment variable to point to the top level
directory:$exportPYTHONPATH=<UGE_PYCL_ROOT>Note that the above step is not needed if UGE PyCL egg package is
installed.Source the appropriate UGE setup file:$source<SGE_ROOT>/<SGE_CELL>/settings.shList queues using QconfApi object:$python-c"from uge.api import QconfApi; api = QconfApi(); print api.list_queues()"Running Test SuiteSetup PYTHONPATH environment variable to point to the top level
directory:$exportPYTHONPATH=<UGE_PYCL_ROOT>This step is not needed if UGE PyCL egg package is installed.Source the appropriate UGE setup file:$source<SGE_ROOT>/<SGE_CELL>/settings.shRun test suite:adjust test_values.json according to your needs, esp. the host_names
have to be resolvable, otherwise some execution host tests might fail$maketest
Package: ug-gpib
ug_gpibA Python3 pyUSB driver for the LQ Electronics Corp UGPlus USB to GPIB Controller.Tested using Linux, should work for Mac OSX, Windows and any OS with PythonpyUSBsupport.:warning:The device must be IEEE 488.1 compliant. It must assert the EOI line to signal the end of a line. If this is
not the case, the controller cannot be used. Older devices, typically only send CR, LF, or CR-LF.TheUGPlusis a fairly cheap controller, that supports
simple GPIB read and write operations only. It does not support advanced GPIB features like serial polling for example,
and it does not have line drivers to support long cables and lots of devices on the bus.The UGPlus does have several firmware bugs, I have tried to mitigate them to the best of my knowledge. Seebelowfor details.If you are looking for advanced features I suggest buying either a Prologix GPIB adapter or one of the NI USB adapters.
I can recommend the following libraries for bothPrologix GPIB adapterandLinux GPIB.The library is fully type-hinted.SetupTo install the library in a virtual environment (always use venvs with every project):virtualenvenv# virtual environment, optionalsourceenv/bin/activate
pipinstallug-gpibLinuxTo access the raw usb port in Linux, root privileges are required. It is possible to use udev to change ownership of the
usb port on creation. This can be done via a rules file.sudocp98-ugsimple.rules/etc/udev/rules.d/.
sudoudevadmcontrol--reload-rulesUsageInitialize UGSimpleGPIBfromug_gpibimportUGPlusGpibgpib_controller=UGPlusGpib()Writing "*IDN?" a command to address 0x02. Do note the GPIB commands must be byte strings.gpib_controller.write(2,b"*IDN?\n")Reading from address 0x02 and decoding the byte string to a unicode string.data=gpib_controller.read(2)print(data.decode())Seeexamples/for more working examples. Including an example that shows how to use the library from the
command line.Firmware BugsThere are several bugs in the firmware of the UGPlus most of those are off-by-one errors and consequently out-of-bounds
reads. I documented themhere.
Some of these bugs are also evident when using the software supplied by the manufacturer.
The most obvious ones are the following:Out-of-bounds read when reading the firmware version. The controller sends one more byte than requested.Out-of-bounds read when discovering GPIB devices. The controller sends one more byte than requested.Out-of-bounds read when the GPIB device does not return any data. The controller sends one more byte than requested.VersioningI useSemVerfor versioning. For the versions available, see thetags on this repository.DocumentationI use theNumpydocstyle for documentation.AuthorsJacob Alexander-Initial work for the UGSimpleJacob AlexanderPatrick Baus-Complete rewrite for the UGPlus-PatrickBausLicenseThis project is licensed under the GPL v3 license - see theLICENSEfile for details
Package: uglychain
UglyChain⚡ UglyChain：更好用的 LLM 应用构建工具 ⚡Explore the docs »Report Bug·Request Feature🤔 What is UglyChain?现在有很多利用大模型 LLM 进行应用构建的工具，最有名的就是 LangChain。早期的 LangChain 整个框架并不完善，很多并不直观的定义和调用方式，以及将内部功能封装得太彻底，使的难以定制化的更充分的利用大模型的能力来解决问题。所以我就开发的最初的 UglyGPT（UglyChain的原型），试图解决这个问题。到了今天，GPTs 也已经面世很长时间了，也有了越来越多的 LLM 应用构建工具。但是这些工具都有一个共同的问题：不够直观。
从底层来说，现在的大模型是基于 Chat 进行接口交互的，这对于应用开发而言并不友好，因为应用开发更多的是模板化的结构化内容生成，而不是对话式的交互。所以我们需要一个对应用开发更加友好的接口，这就是 UglyChain 的初衷。Features📦 对大模型接口进行封装，提供对工程化更加直观易懂的交互方式，而不是传统的对话式交互。可以参数化 Prompt，更加方便地进行批量调用可以对 Prompt 进行结构化返回，方便后续处理可以对 Prompt 进行角色设置，方便模型进行角色扮演（这个过程无需操控 Message）🔗 对大模型的高级调用进行封装，提供更加方便的交互方式提供了类似于 MapReduce 的功能，可以通过 MapChain 对多个 Prompt 进行并行调用，也可以用 ReduceChain 对多个 Prompt 进行串行调用大模型最优质的能力之一就是拥有 ReAct 能力。我们提供了 ReActChain 便捷的实现这种能力。💾 提供了搜索引擎的封装，可以方便地进行搜索引擎的调用。注意我们只封装了搜索过程的调用，而没有提供搜索引擎的搭建。如果要构建基于 RAG 的应用，需要利用其他的工具完成资料库的建立，而我们只提供对资料库搜索功能的封装。Getting StartedWith pip:pipinstalluglychainUsageLLM这是最基础的模型调用类，其他的高级类也都继承和使用了这个类的基本功能。快速使用：fromuglychainimportLLM,Modelllm=LLM()print(llm("你是谁？"))# 与模型对话，返回字符串的回答调整基础配置选项：llm=LLM(model=Model.YI)# 可以选择更多的模型，如 Model.GPT3_TURBO、Model.GPT4 等等llm=LLM(system_prompt="我想让你担任职业顾问。我将为您提供一个在职业生涯中寻求指导的人，您的任务是帮助他们根据自己的技能、兴趣和经验确定最适合的职业。您还应该对可用的各种选项进行研究，解释不同行业的就业市场趋势，并就哪些资格对追求特定领域有益提出建议。")# 可以对模型设置角色，这样模型就会以这个角色的视角来回答问题。设置的内容保存在 System Message 中。参数化 prompt：llm=LLM(prompt_template="{object}的{position}是谁？")print(llm(object="《红楼梦》",position="作者"))print(llm(object="上海市",position="市长"))对于 prompt 中只有一个参数的情况，可以直接传入参数：llm=LLM("介绍一下{object}")print(llm("Transformer"))结构化返回结果：classUserDetail(BaseModel):name:strage:intllm=LLM(response_model=UserDetail)print(llm("Extract Jason is 25 years old"))# UserDetail(name='Jason', age=25)MapChain这是一个可以并行对同类型 Prompt 进行调用的类，可以大大提高调用效率。快速使用：fromuglychainimportMapChainllm=MapChain()print(llm([{"input":"How old are you?"},{"input":"What is the meaning of life?"},{"input":"What is the hottest day of the year?"},]))类似于 LLM，也可以对 MapChain 进行更高阶的使用：classAUTHOR(BaseModel):name:str=Field(...,description="姓名")introduction:str=Field(...,description="简介")llm=MapChain(prompt_template="{book}的{position}是谁？",response_model=AUTHOR,map_keys=["book",])input=["《红楼梦》","《西游记》","《三国演义》","《水浒传》",]print(llm(book=input,position="作者"))Roadmap增加 FunctionCall 的能力增加 Memory 的能力ContributingContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make aregreatly appreciated.If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!Fork the ProjectCreate your Feature Branch (git checkout -b feature/AmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull RequestLicenseDistributed under the MIT License. SeeLICENSE.txtfor more information.
Package: ugly-code
ugly-code[TOC]安装$pipinstallugly-codeCommand 工具自动注入命令行参数到函数 (ugly_code.cmd.Command)创建测试文件cmd_debug.pyfromugly_code.cmdimportCommand@Commanddefmain(x:int,y,z=1023):"""测试一下"""print("{x}\t{y}\t{z}".format(**locals()))if__name__=='__main__':globals()['main']()执行该文件$pythoncmd_debug.py-x1023-y33310233331023有默认值的参数会被设置为可选参数,无默认值则设置为必选.使用Type Hints的参数可自动进行类型检查.使用 CMDHolder持有 Command创建命令行工具组编辑文件cmd_debug.pyfromugly_code.cmdimportCMDHolder@CMDHolder.command("test","测试")defmain(x:int,b:str,c:int=1):"""测试一下"""print("{x}\t{y}\t{z}".format(**locals()))@CMDHolder.command("echo","echo")defecho(words):"""echo"""print(words)if__name__=='__main__':CMDHolder(__name__).execute()执行该文件:$ python3 cmd_debug.py echo -words "测试"
测试
$ python3 cmd_debug.py test
usage: Command line create by ugly-code.

    测试一下
     [-h] -x X -b B [-c C]
Command line create by ugly-code.

    测试一下
    : error: the following arguments are required: -x, -b由示例可发现，CMDHolder可以持有多个命令行工具，根据不同的参数调用不同的命令行对象。而且还可以自定义命令行工具的名称与介绍。多进程管理工具(ugly_code.runit)ugly_code.runit多任务管理工具。使用Runner和Worker管理多进程程序。支持XML-RPC控制任务启停。一个Worker对应一个进程，各进程使用tag区分。使用方式:
注册任务到Runner，启动Runner即可自动\手动启动任务或使用XML-RPC接口对任务进行调度管理。示例importthreadingimporttimefromugly_code.runitimportSwitch,Worker,RunnerclassAWorker(Worker):defserve(self):whileself.switch.on:print(f"{self.switch.name}{time.time()}")time.sleep(3.0)defclose_it(switch:Switch):time.sleep(10)switch.close()if__name__=='__main__':st=Switch('Runner')threading.Thread(target=close_it,args=(st,)).start()Runner(st,(("a",AWorker),('b',AWorker)),m=('127.0.0.1',0)).run()使用xml-rpc管理进程importthreadingimporttimefromugly_code.runitimportWorker,Runner,RuntItMonitorclassAWorker(Worker):defserve(self):whileself.switch.on:print(f"{self.switch.name}{time.time()}")time.sleep(3.0)defstart_and_close_task(m,tag):time.sleep(10)monitor=RuntItMonitor(m)monitor.start(tag)monitor.start(tag)time.sleep(3)print(monitor.stats())monitor.close(tag,True)time.sleep(3)monitor.prune()print(monitor.stats())monitor.shutdown()if__name__=='__main__':m=('127.0.0.1',65432)runner=Runner(None,(("a",AWorker,0,0,False),('b',AWorker)),m=m)threading.Thread(target=start_and_close_task,args=("http://{}:{}".format(*m),"a",)).start()runner.run()查看文档扩展工具集对象代理工具fromugly_code.eximportObjectProxyobj=ObjectProxy(dict(a=1,b=2,c=3,d=dict(a=1,b=2)))print(obj.d.a)RabbitMQ监听工具安装$pipinstallugly-code[rabbit]示例importthreadingimporttimefrompikaimportBasicPropertiesfrompika.adapters.blocking_connectionimportBlockingChannelfrompika.specimportBasicfromugly_code.rabbitimportListenOpt,default_listen_ctx,RabbitListenCtxopt=ListenOpt(queue='test',uri="amqp://guest:guest@127.0.0.1:5672/test",exchange='test',ext='direct',routing_key='test',durable=True,prefetch=1,retry_delay=1.0,retry=False)defhandle_message(channel:BlockingChannel,deliver:Basic.Deliver,props:BasicProperties,body:bytes):print(body)channel.connection.process_data_events(3)defclose_it(val:RabbitListenCtx):time.sleep(10)val.shutdown()withdefault_listen_ctx(opt).start(handle_message)asctx:threading.Thread(target=close_it,args=(ctx,)).start()更多说明
Package: ugly-csv-generator
Python package to automatically uglify CSVs. Why?
To improve the testing capabilities of pipelines that
must be able to support strongly malformed input data.All the malformation automated here are non-destructive,
meaning they introduce confusion in the data but do not
any information.The inspiration for the automated malformation are
all from real-life CSVs (sigh)Humans will always surprise us with the ever-new
malformed input data, but hey, we can try to best
ruining the test CSVs!How do I install this package?As usual, just download it using pip:pipinstallugly_csv_generatorTests CoverageSince some software handling coverages sometime
get slightly different results, here’s three of them:Python package to generate ugly real-looking csvs.Usage exampleTo ruin a CSV you can use the following snippet.
In the following example we use a tool to generate
a random sanitized csv.fromrandom_csv_generatorimportrandom_csvfromugly_csv_generatorimportuglifycsv=random_csv(5)# CSV with 5 linescsv=csv[csv.columns[:3]]# We will use only the first 3 columns for this exampleugly=uglify(csv)The initial CSV will look something like:regionprovincesurnamePugliaLecceRighettiCampaniaNapoliGovoniEmilia RomagnaReggio EmiliaVichiLombardiaLeccoCostaUmbriaPerugiaFabbroThe result uglified CSV will look something like this:012345nannannannannannanregion-1regionregion 0provincesurnamenannannannannannannannannannannannannannannannannannannannanregionnanprovincesurnamenannanregionnanprovincesurnamenannanPugliananLecceRighettinannanCampaniananNapoliGovoninannanEmilia RomagnananReggio EmiliaVichinannanLombardiananLeccoCostanannanUmbriananPerugiaFabbronannannannannannannannannannannannannanThe uglify method offers numerous keyword parameters,
since the library is currently in quick evolution
if you are interested in them just check out the
code documentation.