| Home | Trees | Index | Help |
|
|---|
|
|
Cheesecake: How tasty is your code?
The idea of the Cheesecake project is to rank Python packages based on various empirical "kwalitee" factors, such as:
- whether the package can be downloaded from PyPI given its name
- whether the package can be unpacked
- whether the package can be installed into an alternate directory
- existence of certain files such as README, INSTALL, LICENSE, setup.py etc.
- percentage of modules/functions/classes/methods with docstrings
- ... and many others
|
|||
| NameSetter | |||
| Index | Class describing one index. | ||
| OneOf | |||
| FilesIndex | |||
| IndexUrlDownload | Give points for successful downloading of a package. | ||
| IndexUnpack | Give points for successful unpacking of a package archive. | ||
| IndexUnpackDir | Check if package unpack directory resembles package archive name. | ||
| IndexSetupPy | Reward packages that have setup.py file. | ||
| IndexInstall | Check if package can be installed via "python setup.py" command. | ||
| IndexPyPIDownload | Check if package was successfully downloaded from PyPI and how far from it actual package was. | ||
| IndexGeneratedFiles | Lower score for automatically generated files that should not be present in a package. | ||
| IndexInstallability | |||
| IndexRequiredFiles | Check for existence of important files, like README or INSTALL. | ||
| IndexDocstrings | Compute how many objects have relevant docstrings. | ||
| IndexFormattedDocstrings | Compute how many of existing docstrings include any formatting, like epytext or reST. | ||
| IndexDocumentation | |||
| IndexUnitTests | Compute unittest index as percentage of methods/functions that are exercised in unit tests. | ||
| IndexUnitTested | Check if the package have unit tests which can be easily found by any of known test frameworks. | ||
| IndexPyLint | Compute pylint index of the whole package. | ||
| IndexCodeKwalitee | |||
| CheesecakeError | Custom exception class for Cheesecake-specific errors. | ||
| CheesecakeIndex | |||
| Step | Single step during computation of package score. | ||
| StepByVariable | Step which is always run if given Cheesecake instance variable is true. | ||
| Cheesecake | Computes 'goodness' of Python packages. | ||
|
|||
| sorted(L) | |||
|
isiterable(obj)
Check whether object is iterable. |
|||
|
has_extension(filename,
ext)
Check if filename has given extension. |
|||
|
discover_file_type(filename)
Discover type of a file according to its name and its parent directory. |
|||
|
get_files_of_type(file_list,
file_type)
Return files from file_list that match given file_type.
|
|||
|
get_package_name_from_path(path)
Get package name as file portion of path. |
|||
|
get_package_name_from_url(url)
Use urlparse to obtain package name from URL. |
|||
|
get_package_name_and_type(package,
known_extensions)
Return package name and type. |
|||
|
get_method_arguments(method)
Return tuple of arguments for given method, excluding self. |
|||
|
get_attributes(obj,
names)
Return attributes dictionary with keys from names.
|
|||
|
camel2underscore(name)
Convert name from CamelCase to underscore_name. |
|||
|
index_class_to_name(clsname)
Covert index class name to index name. |
|||
|
is_empty(path)
Returns True if file or directory pointed by path is empty.
|
|||
|
strip_dir_part(path,
root)
Strip root part from path.
|
|||
|
get_files_dirs_list(root)
Return list of all files and directories below root.
|
|||
|
length(L)
Overall length of all strings in list. |
|||
|
generate_arguments(arguments,
max_length)
Pass list of strings in chunks of size not greater than max_length. |
|||
| make_indices_dict(indices) | |||
|
WithOptionalExt(name,
extensions)
Handy way of writing Cheese rules for files with extensions. |
|||
| Doc(name) | |||
|
process_cmdline_args()
Parse command-line options. |
|||
|
main()
Display Cheesecake index for package specified via command-line options. |
|||
|
|||
|
Check whether object is iterable.
>>> isiterable([1,2,3])
True
>>> isiterable("string")
True
>>> isiterable(object)
False
|
Check if filename has given extension.
>>> has_extension("foobar.py", ".py")
True
>>> has_extension("foo.bar.py", ".py")
True
>>> has_extension("foobar.pyc", ".py")
False
|
Discover type of a file according to its name and its parent directory.
>>> discover_file_type('module.py')
'module'
>>> discover_file_type('./setup.py')
'special'
>>> discover_file_type('some/directory/junk.pyc')
'pyc'
>>> discover_file_type('examples/readme.txt')
>>> discover_file_type('examples/runthis.py')
'demo'
>>> discover_file_type('optimized.pyo')
'pyo'
>>> test_files = ['ut/test_this_and_that.py', ... 'another_test.py', ... 'TEST_MY_MODULE.PY'] >>> for filename in test_files: ... assert discover_file_type(filename) == 'test', filename
>>> discover_file_type('this_is_not_a_test_really.py')
'module'
|
Return files from >>> file_list = ['test/test_foo.py', 'setup.py', 'README', 'test/test_bar.py'] >>> get_files_of_type(file_list, 'test') ['test/test_foo.py', 'test/test_bar.py'] |
Get package name as file portion of path.
>>> get_package_name_from_path('/some/random/path/package.tar.gz')
'package.tar.gz'
>>> get_package_name_from_path('/path/underscored_name.zip')
'underscored_name.zip'
>>> get_package_name_from_path('/path/unknown.extension.txt')
'unknown.extension.txt'
|
Use urlparse to obtain package name from URL.
>>> get_package_name_from_url('http://www.example.com/file.tar.bz2')
'file.tar.bz2'
>>> get_package_name_from_url('https://www.example.com/some/dir/file.txt')
'file.txt'
|
Return package name and type. Package type must exists in known_extensions list. Otherwise None is returned.
>>> extensions = ['tar.gz', 'zip']
>>> get_package_name_and_type('underscored_name.zip', extensions)
('underscored_name', 'zip')
>>> get_package_name_and_type('unknown.extension.txt', extensions)
|
Return tuple of arguments for given method, excluding self.
>>> class Class:
... def method(s, arg1, arg2, other_arg):
... pass
>>> get_method_arguments(Class.method)
('arg1', 'arg2', 'other_arg')
|
Return attributes dictionary with keys from Object is queried for each attribute name, if it doesn't have this attribute, default value None will be returned. >>> class Class: ... pass >>> obj = Class() >>> obj.attr = True >>> obj.value = 13 >>> obj.string = "Hello"
>>> d = get_attributes(obj, ['attr', 'string', 'other'])
>>> d == {'attr': True, 'string': "Hello", 'other': None}
True
|
Convert name from CamelCase to underscore_name.
>>> camel2underscore('CamelCase')
'camel_case'
>>> camel2underscore('already_underscore_name')
'already_underscore_name'
>>> camel2underscore('BigHTMLClass')
'big_html_class'
>>> camel2underscore('')
''
|
Covert index class name to index name.
>>> index_class_to_name("IndexDownload")
'download'
>>> index_class_to_name("IndexUnitTests")
'unit_tests'
>>> index_class_to_name("IndexPyPIDownload")
'py_pi_download'
|
path is empty.
|
Strip
>>> strip_dir_part('/home/ruby/file', '/home')
'ruby/file'
>>> strip_dir_part('/home/ruby/file', '/home/')
'ruby/file'
>>> strip_dir_part('/home/ruby/', '/home')
'ruby/'
>>> strip_dir_part('/home/ruby/', '/home/')
'ruby/'
|
Return list of all files and directories below Root directory is excluded from files/directories paths. |
Overall length of all strings in list. >>> length(['a', 'bc', 'd', '', 'efg']) 7 |
Pass list of strings in chunks of size not greater than max_length. >>> for x in generate_arguments(['abc', 'def'], 4): ... print x ['abc'] ['def'] >>> for x in generate_arguments(['a', 'bc', 'd', 'e', 'f'], 2): ... print x ['a'] ['bc'] ['d', 'e'] ['f']
|
|
Handy way of writing Cheese rules for files with extensions.
|
|
|
|
| Home | Trees | Index | Help |
|
|---|
| Generated by Epydoc 3.0alpha2 on Sat Aug 12 02:53:38 2006 | http://epydoc.sf.net |