diff options
author | 2009-07-08 20:20:04 +0200 | |
---|---|---|
committer | 2009-07-08 20:20:04 +0200 | |
commit | f6f5b9d9b73ad775cd58ebd49b35b678cc3dbdda (patch) | |
tree | 7fff7dc3713c38da0ede4d6db6f8c2cb9aa2a762 /src | |
parent | Added dependencies to protocol (diff) | |
download | collagen-f6f5b9d9b73ad775cd58ebd49b35b678cc3dbdda.tar.gz collagen-f6f5b9d9b73ad775cd58ebd49b35b678cc3dbdda.tar.bz2 collagen-f6f5b9d9b73ad775cd58ebd49b35b678cc3dbdda.zip |
Added basic functions of DbIface interface
so far only adding, querying will be added later on
Diffstat (limited to 'src')
-rw-r--r-- | src/matchbox/db/__init__.py | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/src/matchbox/db/__init__.py b/src/matchbox/db/__init__.py new file mode 100644 index 0000000..acd8323 --- /dev/null +++ b/src/matchbox/db/__init__.py @@ -0,0 +1,155 @@ +try: + import psycopg2 as dbapi +except ImportError: + print "Error importing psycopg package. Check your dependencies!!" + sys.exit(1) + + +class DbIface(object): + """ + Class representing interface to database for Matchbox + + All of these functions have to be implemented in subclasses + for Matchbox to work correcly + """ + + def __init__(self, dbcon): + raise NotImplementedError("DbIface is only interface, create real object for database functions") + + def add_package(self, name): + """ + @param name: name of package to add without category or version (e.g. kdevelop) + @type name: string + + @rtype: integer + @returns: id of package added to database + """ + pass + + def add_category(self, name): + """ + @param name: name of category to add + @type name: string + + @rtype: integer + @returns: id of category added to database + """ + pass + + def add_package_version(self, package_id, category_id, version): + """ + @param package_id: id of row in package table + @type package_id: integer + @param category_id: id of row in category table + @type category_id: integer + @param version: version string to add (including revision) + @type version: string + + @rtype: integer + @returns: id of package version added + """ + pass + + def add_dependency(self, packageversion_id, dependency_id): + """ + Adds dependency that package was compiled with + + @param packageversion_id: id of row in packageversion table + @type packageversion_id: integer + @param dependency_id: id of row in packageversion table + @type dependency_id: integer + """ + pass + + def add_package_info(self, pi): + """ + @param pi: package info to add to database + @type pi: protocol.PackageInfo + + @rtype: integer + @returns: id of package info added to database + """ + pass + + def add_tinderbox(self, ip): + """ + @param ip: ip address of tinderbox slave + @type ip: string in form of xxx.xxx.xxx.xxx + """ + pass + + def add_attachment(self, packageproperties_id, name, content, mimetype): + """ + @param packageproperties_id: id of row in packageproperties table + @type packageproperties_id: integer + @param name: name of attachment (usually filename) + @type name: string + @param content: data of attachment + @type content: string blob + @param mimetype: mime-type of attachment (e.g. text/html, text/plain etc) + @type mimetype: string + """ + pass + + def add_portage_profile(self, name): + """ + @param name: name of portage profile to add + @type name: string + + @rtype: integer + @returns: row id of profile added to database + """ + pass + + + def add_useflag(self, name): + """ + @param name: name of use flag to add + @type name: string + + @rtype: integer + @returns: row id of use flag added to database + """ + pass + + def add_packageproperties(self, packageversion_id, profile_id, tinderbox_id, error_code): + """ + + @param packageversion_id: id of row in packageversion table + @type packageversion_id: integer + @param profile_id: id of row in portageprofile table + @type profile_id: integer + @param tinderbox_id: id of row in tinderbox_id + @type tinderbox_id: integer + @param error_code: error code for this compile try + @type error_code: integer + + @returns: row id of packageproperties added to database + @rtype: integer + """ + pass + + def add_useflags_to_packageproperies(self, packageproperties_id, useflag_ids): + """ + @param packageproperties_id: id of row in packageproperies table + @type packageproperties_id: integer + @param useflag_ids: list of row ids in useflag table + @type useflag_ids: list + """ + pass + + def add_contents_to_packageproperties(self, packageproperties_id, contents): + """ + @param packageproperties_id: id of row in packageproperties table + @type packageproperties_id: integer + @param contents: dict of files in packageproperties (path is key, ) + @param path: path to add to database + @type path: string + @param type: type of file to add as returned from dblink.getcontents() (e.g. 'dir', 'obj' or 'sym') + @type type: string + @param size: size of file or 0 if not regular file + @type size: integer + @param hash: hash of file or None if not regular file + @type hash: 32 character string + """ + pass |