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

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

Serving Software Downloads in 976 Categories, Downloaded 30.066.737 Times

Baker for Linux 1.1

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

Baker for Linux

Report Broken Link
Printer Friendly Version


Product Homepage
Download (16 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
BAKER FOR LINUX RELATED
Utilities  -  ubuntu-perfeito 9.29
hdparm project is a Linux shell utility for viewing and manipulating various IDE drive and driver parameters. Most drives can benefit from improved performance using a command similar to "hdparm -qm8 -qu1 -qc1 -qd1 /dev/hda".
112.64 KB  
Utilities  -  System-7 Linux Alpha test 1
System-7 Linux strives to set itself apart from other linux distros by tredding waters not offen attempted. These are the waters of package unity. This means where most distros support 1 standard package format, System-7 will support most major...
492.9 MB  
Database Tools  -  AnyMeal 0.30
AnyMeal is a Linux recipe database software offering recipe management for a cookbook with more than 100,000 recipes, allowing to search, display and edit them. AnyMeal is designed to be lean and flexible. Happy cooking! AnyMeal has reached the...
1024 KB  
Business  -  newslite 1.7
newslite is a UNIX/LINUX command line tool to download from newsgroup and decode multipart and monopart yENC and UU (Unix-to-Unix) encoded files..
39.94 KB  
Icon Tools  -  BlankOn 1.0
BlankOn is a Gnome icon theme and they are the default icon theme for BlankOn Linux..
624.64 KB  
Database Tools  -  AnyMeal 0.30
AnyMeal is a Linux recipe database software offering recipe management for a cookbook with more than 100,000 recipes, allowing to search, display and edit them. AnyMeal is designed to be lean and flexible. Happy cooking! AnyMeal has...
 
Programming  -  PICPrg - Fast PIC Programmer 3.1
PICPrg is a fast Linux command line (or ncurses) program, to program any Microchip PIC microcontroller using the PC parallel port interface. Any parallel port PIC programmer hardware can be used, simply edit the configuration file or use the...
10.24 KB  
Utilities  -  fileschanged 0.6.5
fileschanged is a GNU/Linux command-line utility that reports when files have been altered. Go to the Download Section if you want to download fileschanged. This software is a client to FAM (File Alteration Monitor) servers (FAM,...
266.24 KB  
Utilities  -  Hedinux GNU/Linux 2006.1 Alpha2
Hedinux distribution (formerly Octoz) GNU/Linux is an independently developed desktop OS with ease-of-use as its prime objective. The distribution comes in two editions - a minimalist live CD with the XFce desktop, and a netinstall CD which...
603 MB  
Programming  -  PCTel Modem-Linux Compatiilty Dataase b
The Unofficial PCTel Modem-Linux Compatibilty Database is an effort to collect and categorise information regarding PCTel softmodems' compatibilty in Linux.
28.45 KB  
NEW DOWNLOADS IN LINUX SOFTWARE, PROGRAMMING
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  
Linux Software  -  SLAX 6.0+
Slax is a modern, portable, small and fast Linux operating system with a modular approach and outstanding design. Despite its small size, Slax provides a wide collection of pre-installed software for daily use, including a well organized graphical...
190 KB  
Linux Software  -  GTK+ 2.5
GTK+, which stands for the GIMP Toolkit, is a library for creating graphical user interfaces for the X Window System. It is designed to be small, efficient, and flexible. GTK+ is written in C with a very object-oriented approach. Language bindings...
60 MB  
Programming  -  FLEX-db Digital Asset Manager 3.0.9
FLEX-db - an enterprise Digital Asset Manager (DAM). It ingests and links metadata with files, creates thumbnails, and processes files using business rules. FLEX-db has a JSP client, Java app server for file input and output and an EJB metadata...
21.57 MB  
Programming  -  Libicom 0.9.0
The libicom library is a character based dynamicly linked library for Linux. It is used to remotely control the Icom IC-R8500 wide band receiver via an RS232 link. All call and return parameters to the control functions are character string based....
20.48 KB  
Programming  -  dotdesktop 0.3
Dotdesktop library provides ability to parse desktop entry file and access the information in a convenient way. Desktop entry file format is defined by freedesktop.org, it is used to describe information about an application such as the name and...
327.68 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  -  libyasl 0.2
Libyasl is a C++ class library to easily realize TCP/UDP/Multicast clientsand servers in IPv4 and IPv6 environments under GNU/Linux systems.
143.36 KB