seqenv.common package¶
Submodules¶
seqenv.common.autopaths module¶
-
class
seqenv.common.autopaths.DirectoryPath(path)[source]¶ Bases:
str-
absolute_path¶ The absolute path starting with a /
-
directory¶ The full path of directory containing this one
-
exists¶ Does it exist in the file system?
-
is_symlink¶ Is this directory a symbolic link to an other directory?
-
name¶ Just the directory name
-
permissions¶ Convenience object for dealing with permissions.
-
-
class
seqenv.common.autopaths.FilePath(path)[source]¶ Bases:
strI can never remember all those darn os.path commands, so I made a class that wraps them with an easier and more pythonic syntax.
path = FilePath(‘/home/root/text.txt’) print path.extension print path.directory print path.filenameYou can find lots of the common things you would need to do with file paths. Such as: path.make_executable() etc etc.
-
absolute_path¶ The absolute path starting with a /
-
count_bytes¶ The number of bytes
-
count_lines¶
-
directory¶ The directory containing this file
-
exists¶ Does it exist in the file system. Returns True or False.
-
extension¶ The extension with the leading period
-
filename¶ Just the filename with the extension
-
link_from(path, safe=False)[source]¶ Make a link here pointing to another file somewhere else. The destination is hence self.path and the source is path.
-
link_to(path, safe=False, absolute=True)[source]¶ Create a link somewhere else pointing to this file. The destination is hence path and the source is self.path.
-
prefix¶ Just the filename without the (last) extension and trailing period
-
prefix_path¶ The full path without the (last) extension and trailing period
-
size¶ Human readable file size
-
-
class
seqenv.common.autopaths.FilePermissions(path)[source]¶ Bases:
objectContainer for reading and setting a files permissions
-
number¶ The permission bits as an octal integer
-
-
class
seqenv.common.autopaths.Filesize(size)[source]¶ Bases:
objectContainer for a size in bytes with a human readable representation Use it like this:
>>> size = Filesize(123123123) >>> print size '117.4 MiB'
-
chunk= 1000¶
-
precisions= [0, 0, 1, 2, 2, 2]¶
-
units= ['bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']¶
-
seqenv.common.cache module¶
-
class
seqenv.common.cache.class_property[source]¶ Bases:
propertyYou can use this like this: class Foo(object):
@class_property @classmethod @cached def bar(cls):
return 1+1
-
seqenv.common.cache.property_cached(f)[source]¶ Decorator for properties evaluated only once. It can be used to created a cached property like this:
- class Employee(object):
@property_cached def salary(self):
print “Evaluating...” return time.time()
bob = Employee() print bob.salary bob.salary = “10000$” print bob.salary
seqenv.common.color module¶
-
class
seqenv.common.color.Color[source]¶ Shortcuts for the ANSI escape sequences to control formatting, color, etc. on text terminals. Use it like this:
print Color.red + “Hello world” + Color.end-
b_blk= '\x1b[1;30m'¶
-
b_blu= '\x1b[1;34m'¶
-
b_cyn= '\x1b[1;36m'¶
-
b_grn= '\x1b[1;32m'¶
-
b_pur= '\x1b[1;35m'¶
-
b_red= '\x1b[1;31m'¶
-
b_wht= '\x1b[1;37m'¶
-
b_ylw= '\x1b[1;33m'¶
-
blk= '\x1b[0;30m'¶
-
blu= '\x1b[0;34m'¶
-
bold= '\x1b[1m'¶
-
cyn= '\x1b[0;36m'¶
-
end= '\x1b[0m'¶
-
f_blk= '\x1b[40m'¶
-
f_blu= '\x1b[44m'¶
-
f_cyn= '\x1b[46m'¶
-
f_grn= '\x1b[42m'¶
-
f_pur= '\x1b[45m'¶
-
f_red= '\x1b[41m'¶
-
f_wht= '\x1b[47m'¶
-
f_ylw= '\x1b[43m'¶
-
flash= '\x1b[5m'¶
-
g_blk= '\x1b[5;30m'¶
-
g_blu= '\x1b[5;34m'¶
-
g_cyn= '\x1b[5;36m'¶
-
g_grn= '\x1b[5;32m'¶
-
g_pur= '\x1b[5;35m'¶
-
g_red= '\x1b[5;31m'¶
-
g_wht= '\x1b[5;37m'¶
-
g_ylw= '\x1b[5;33m'¶
-
grn= '\x1b[0;32m'¶
-
i_blk= '\x1b[3;30m'¶
-
i_blu= '\x1b[3;34m'¶
-
i_cyn= '\x1b[3;36m'¶
-
i_grn= '\x1b[3;32m'¶
-
i_pur= '\x1b[3;35m'¶
-
i_red= '\x1b[3;31m'¶
-
i_wht= '\x1b[3;37m'¶
-
i_ylw= '\x1b[3;33m'¶
-
italic= '\x1b[1m'¶
-
l_blk= '\x1b[2;30m'¶
-
l_blu= '\x1b[2;34m'¶
-
l_cyn= '\x1b[2;36m'¶
-
l_grn= '\x1b[2;32m'¶
-
l_pur= '\x1b[2;35m'¶
-
l_red= '\x1b[2;31m'¶
-
l_wht= '\x1b[2;37m'¶
-
l_ylw= '\x1b[2;33m'¶
-
light= '\x1b[2m'¶
-
pur= '\x1b[0;35m'¶
-
red= '\x1b[0;31m'¶
-
u_blk= '\x1b[4;30m'¶
-
u_blu= '\x1b[4;34m'¶
-
u_cyn= '\x1b[4;36m'¶
-
u_grn= '\x1b[4;32m'¶
-
u_pur= '\x1b[4;35m'¶
-
u_red= '\x1b[4;31m'¶
-
u_wht= '\x1b[4;37m'¶
-
u_ylw= '\x1b[4;33m'¶
-
underline= '\x1b[4m'¶
-
wht= '\x1b[0;37m'¶
-
ylw= '\x1b[0;33m'¶
-
seqenv.common.database module¶
-
class
seqenv.common.database.Database(path, factory=None, text_fact=None, isolation=None, retrieve=None, md5=None)[source]¶ Bases:
seqenv.common.autopaths.FilePath-
add(entries, table=None, columns=None, ignore=False)[source]¶ Add entries to a table. The entries variable should be an iterable.
-
add_by_steps(entries_by_step, table=None, columns=None)[source]¶ Add entries to the main table. The entries variable should be an iterable yielding iterables.
-
add_table(name, columns, type_map=None, if_not_exists=False)[source]¶ Add add a new table to the database. For instance you could do this: self.add_table(‘data’, {‘id’:’integer’, ‘source’:’text’, ‘pubmed’:’integer’})
-
columns¶ The list of columns available in every entry.
-
connection¶ To be used externally by the user.
-
create(columns, type_map=None, overwrite=False)[source]¶ Create a new database with a certain schema.
-
cursor¶ To be used externally by the user.
-
first¶ Just the first entry.
-
frame¶ The main table as a blaze data structure. Not ready yet.
-
get_and_order(ids, column=None, table=None)[source]¶ Get specific entries and order them in the same way.
-
get_columns_of_table(table=None)[source]¶ Return the list of columns for a particular table by querying the SQL for the complete list of column names.
-
last¶ Just the last entry.
-
main_table¶
-
own_connection¶ To be used internally in this object.
-
own_cursor¶ To be used internally in this object.
-
prepare()[source]¶ Check that the file exists, optionally downloads it. Checks that the file is indeed an SQLite3 database. Optionally check the MD5.
-
tables¶ The complete list of SQL tables.
-
seqenv.common.git module¶
-
class
seqenv.common.git.GitRepo(path)[source]¶ Bases:
objectA git repository with some convenience methods.
-
branch¶ For instance: u’master’
-
hash¶ For instance: u’f0c796dae64a5a118d88e60523c011d535e8c476’
-
remote_branch¶ For instance: u’origin/master’
-
short_hash¶ For instance: u’f0c796dae64a5a118d88e60523c011d535e8c476’
-
tag¶ For instance: u‘1.0.3-69-gf0c796d-dirty’
-
seqenv.common.timer module¶
seqenv.common.tmpstuff module¶
Module contents¶
-
class
seqenv.common.GenWithLength(gen, length)[source]¶ Bases:
objectA generator with a length attribute
-
seqenv.common.download_from_url(source, destination, progress=False, uncompress=True)[source]¶ Download a file from an URL and place it somewhere. Like wget. Uses requests and tqdm to display progress if you want. By default it will uncompress files.
-
seqenv.common.flatter(x)¶