Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 956 Categories, Downloaded 50.356.727 Times

Baker for Linux 1.1

Company: Matt Chaput
Date Added: September 22, 2013  |  Visits: 682

Baker for Linux

Report Broken Link
Printer Friendly Version


Product Homepage
Download (38 downloads)



# An imaginary script full of useful Python functions<br /><br />@baker.command<br />def set(name, value=None, overwrite=False):<br /> """Sets the value of a key in the database.<br /><br /> If you don't specify a value, the named key is deleted. Overwriting<br /> a value may not be visible to all clients until the next full sync.<br /> """<br /><br /> db = get_database()<br /> if overwrite or name not in db:<br /> if value is None:<br /> db.delete(name)<br /> print "Deleted %s" % name<br /> else:<br /> db.set(name, value)<br /> print "Set %s to %s" % (name, value)<br /> else:<br /> print "Key exists!"<br /><br />@baker.command<br />def get(name):<br /> "Prints the value of a key in the database."<br /><br /> db = get_database()<br /> print db.get(name)<br /><br />baker.run()<br /><br />You can then run the script and use your function names and parameters as the command line interface, using optparse-style options:<br /><br />$ script.py set alfa bravo<br />Set alfa to bravo<br /><br />$ script.py set --overwrite alfa charlie<br />Set alfa to charlie<br /><br />$ script.py get alfa<br />charlie<br /><br />$ script.py --help<br /><br />Available commands:<br /><br /> get Prints the value of a key in the database.<br /> set Sets the value of a key in the database<br /><br />Use "script.py < command > --help" for individual command help.<br /><br />$ script.py set --help<br /><br />Usage: script.py set < name > [< value >]<br /><br />Sets the value of a key in the database.<br /><br /> If you don't specify a value, the named key is deleted. Overwriting<br /> a value may not be visible to all clients until the next full sync.<br /><br />Options:<br /><br />--overwrite<br /><br />Arguments<br /><br />Baker maps command line options to function parameters in the most natural way available.<br /><br />Bare arguments are used to fill in required parameters:<br /><br />@baker.command<br />def test(a, b, c):<br /> print "a=", a, "b=", b, "c=", c<br /><br />$ script.py test 1 2 3<br />a= 1 b= 2 c= 3<br /><br />--option arguments are used to fill in keyword parameters. You can use --option value or --option=value, as in optparse:<br /><br />@baker.command<br />def test(key="C"):<br /> print "In the key of:", key<br /><br />$ script.py test<br />In the key of: C<br />$ script.py test --key A<br />In the key of: A<br />$ script.py test --key=Gb<br />In the key of: Gb<br /><br />Function parameters where the default is None are considered optional arguments and will be filled if extra arguments are available. Otherwise, extra bare arguments never fill in keyword parameters:<br /><br />@baker.command<br />def test(start, end=None, sortby="time"):<br /> print "start=", start, "end=", end, "sort=", sortby<br /><br />$ script.py --sortby name 1<br />start= 1 end= sortby= name<br />$ script.py 1 2<br />start= 1 end= 2 sortby= time<br /><br />If a keyword parameter's default is an int or float, Baker will try to convert the option's string to the same type:<br /><br />@baker.command<br />def test(limit=10):<br /> print type(limit)<br /><br />$ script.py test --limit 10<br />< type 'int' ><br /><br />If the default of a parameter is a boolean, the corresponding command line option is a flag that sets the opposite of the default:<br /><br />@baker.command<br />def test(name, verbose=False):<br /> if verbose: print "Opening", name<br /><br />$ script.py test --verbose alfa<br />Opening alfa<br /><br />If the function takes * and/or ** parameters, any leftover arguments and options will fill them in.<br /><br />Parameter help<br /><br />Baker lets you specify help for parameters in three ways.<br /><br />In the decorator:<br /><br />@baker.command(params={"force": "Delete even if the file exists"})<br />def delete(filename, force=False):<br /> "Deletes a file."<br /> if force or not os.path.exists(filename):<br /> os.remove(filename)<br /><br />In Python 3.x, you can use parameter annotations to associate doc strings with parameters:<br /><br />@baker.command<br />def delete(filename, force:"Delete even if the file exists."=False):<br /> "Deletes a file."<br /> if force or not os.path.exists(filename):<br /> os.remove(filename)<br /><br />Baker can parse the function's docstring for Sphinx-style :param blocks:<br /><br />@baker.command<br />def delete(filename, force=False):<br /> """Deletes a file.<br /><br /> :param force: Delete even if the file exists.<br /> """<br /> if force or not os.path.exists(filename):<br /> os.remove(filename)<br /><br />Short options<br /><br />To allow single-character short options (e.g. -v for --verbose), use the shortopts keyword on the decorator:<br /><br />@baker.command(shortopts={"verbose": "v"}, params={"verbose", "Spew lots"})<br />def test(verbose=False):<br /> pass<br /><br />$ script.py test --help<br /><br />Usage: script.py test<br /><br />Options:<br /><br /> -v --verbose Spew lots<br /><br />You can group multiple short flag options together (-xvc). You can also optionally not put a space between a short option and its argument, for example -nCASE instead of -n CASE.<br /><br />Miscellaneous<br /><br />Instead of baker.run(), you can use baker.test() to print out how Baker will call your function based on the given command line.<br /><br />As in many UNIX command line utilities, if you specify a single hyphen (-) as a bare argument, any subsequent arguments will not parsed as options, even if they start with --.<br /><br />Commands are automatically given the same name as the decorated function. To give a command a different name, use the name keyword on the decorator. This is especially useful when the command name you want isn't a valid Python identifier:<br /><br />@baker.command(name="track-all")<br />def trackall():<br /> pass<br /><br />You can specify a "default" command that is used when the first argument to the script doesn't look like a command name:<br /><br />@baker.command(default=True)<br />def here(back=False):<br /> print "here! back=", back<br /><br />@baker.command<br />def there(back=False):<br /> print "there! back=", back<br /><br />$ script.py --back<br />here! back= True<br /><br />#md5=2107b353d7506c79ad9ff3eda8f6dd26<br /><br />#md5=8d6a077fea30cfa4f1a57cc7778497e6

Requirements: No special requirements
Platforms: *nix, Linux
Keyword: Argument Arguments Baker Baker Linux Command Database Default Deletefilename Force Function Keyword Linux Option Options Ospathexistsfilename Parameters Parametersbakercommanddef Print Scriptpy Short Verbose
Users rating: 0/10

License: Freeware Size: 10.24 KB
USER REVIEWS
More Reviews or Write Review


BAKER FOR LINUX RELATED
Database Tools  -  DBSync for MS Access & MS SQL 3.5.0
DBSync for MS Access & MSSQL is a database synchronizer which performs MS Access (mdb) to MS SQL server and MSSQL to Access database conversion and synchronization simply by configuring several options in wizard-like application. DBSync for MS...
 
Database Tools  -  DBSync for MSSQL & MySQL 3.7.2
DBSync for MS SQL & MySQL is a database synchronizer which performs SQL to MySQL and MySQL to MS SQL database conversion and synchronization simply by configuring several options in wizard-like application. By following a few steps, you will...
 
Database Tools  -  DBSync for MS SQL & PostgreSQL 2.6.1
DBSync for MS SQL & PostgreSQL is a database synchronizer which performs MS SQL to PostgreSQL and PostgreSQL to MS SQL database conversion and synchronization simply by configuring several options in wizard-like application. This tool gives you...
 
Misc. Web Browser Tools  -  Windows Grep 2.3.0.2403
Windows Grep is an advanced searh tool that improves the default Windows search function with reporting support. Although Windows and many other programs have file searching capabilities built-in, none can match the power and versatility of...
 
Libraries  -  Libopennet 0.9.9
Libopennet is a library that provides the function open_net() which accepts the same parameters as the open() system call, but the pathname argument can be an FTP or HTTP URL. Libopennet project allows you to open_net() files the same way you...
102.4 KB  
Network & Internet  -  w3bfukk0r 0.2
w3bfukk0r is a forced browsing tool which scans Web servers for a directory by using the HTTP HEAD command and a brute force mechanism based on a word list. w3bfukk0r supports HTTP and HTTPS, does banner grabbing, and allows User-Agent faking..
8.19 KB  
Utilities  -  Email2PC 1.0
To give your PC commands you must send email contains the command in the title (not case sensitive): Help - send to me commands list Print this - print the email body Screen - send to me fresh screen shot Startup - add Email2PC to startup Shutdown...
388 KB  
Database Tools  -  FTPSeah rc
FTPSearch is a java-based program that garthers URLs from many ftps and stores them in database to provide search function. Currently Postgres and MySQL are available for data storage.
484.85 KB  
Programming  -  argh 0.14.2
Argh provides a very simple wrapper for argparse. Argparse is a very powerful tool; argh just makes it easy to use. Here???*a*?s a list of features that argh adds to argparse: * mark a function as a CLI command and specify...
10.24 KB  
Programming  -  Argtable for Linux 2.12
Argtable is an ANSI C library for parsing GNU style command line options with a minimum of fuss. It enables a program's command line syntax to be defined in the source code as an array of argtable structs. The command line is then parsed according...
3.2 MB  
NEW DOWNLOADS IN LINUX SOFTWARE, PROGRAMMING
Linux Software  -  EasyEDA PCB Designer for Linux 2.0.0
EasyEDA, a great web based EDA(Electronics Design Automation) tool, online PCB tool, online PCB software for electronics engineers, educators, students, makers and enthusiasts. Theres no need to install any software. Just open EasyEDA in any...
34.4 MB  
Linux Software  -  wpCache® WordPress HTTP Cache 1.9
wpCache® is a high-performance, distributed object, caching system application, generic in nature, but intended for use in speeding up dynamic web applications, by decreasing database load time. wpCache® decreases dramatically the page...
3.51 MB  
Linux Software  -  Polling Autodialer Software 3.4
ICTBroadcast Auto Dialer software has a survey campaign for telephone surveys and polls. This auto dialer software automatically dials a list of numbers and asks them a set of questions that they can respond to, by using their telephone keypad....
488 B  
Linux Software  -  Total Video Converter Mac Free 3.5.5
Total Video Converter Mac Free developed by EffectMatrix Ltd is the official legal version of Total Video Converter which was a globally recognized brand since 2006. Total Video Converter Mac Free is a free but powerful all-in-one video...
17.7 MB  
Linux Software  -  Skeith mod_log_sql Analyzer 2.10beta2
Skeith is a php based front end for analyzing logs for Apache using mod_log_sql.
47.5 KB  
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB