[dak/master] make it safer to do from daklib.dbconn import *
Signed-off-by: Mark Hymers <mhy@debian.org>
---
daklib/dbconn.py | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/daklib/dbconn.py b/daklib/dbconn.py
index 781e648..f1988ca 100755
--- a/daklib/dbconn.py
+++ b/daklib/dbconn.py
@@ -47,6 +47,10 @@ from singleton import Singleton
################################################################################
+__all__ = []
+
+################################################################################
+
class Architecture(object):
def __init__(self, *args, **kwargs):
pass
@@ -54,6 +58,8 @@ class Architecture(object):
def __repr__(self):
return '<Architecture %s>' % self.arch_string
+__all__.append('Architecture')
+
def get_architecture(architecture, session=None):
"""
Returns database id for given C{architecture}.
@@ -76,6 +82,8 @@ def get_architecture(architecture, session=None):
return None
return q.one()
+__all__.append('get_architecture')
+
def get_architecture_suites(architecture, session=None):
"""
Returns list of Suite objects for given C{architecture} name
@@ -99,6 +107,8 @@ def get_architecture_suites(architecture, session=None):
q = q.join(Architecture).filter_by(arch_string=architecture).order_by('suite_name')
return q.all()
+__all__.append('get_architecture_suites')
+
class Archive(object):
def __init__(self, *args, **kwargs):
pass
@@ -106,6 +116,8 @@ class Archive(object):
def __repr__(self):
return '<Archive %s>' % self.name
+__all__.append('Archive')
+
def get_archive(archive, session=None):
"""
returns database id for given c{archive}.
@@ -129,6 +141,7 @@ def get_archive(archive, session=None):
return None
return q.one()
+__all__.append('get_archive')
class BinAssociation(object):
def __init__(self, *args, **kwargs):
@@ -137,6 +150,8 @@ class BinAssociation(object):
def __repr__(self):
return '<BinAssociation %s (%s, %s)>' % (self.ba_id, self.binary, self.suite)
+__all__.append('BinAssociation')
+
class Binary(object):
def __init__(self, *args, **kwargs):
pass
@@ -144,6 +159,8 @@ class Binary(object):
def __repr__(self):
return '<Binary %s (%s, %s)>' % (self.package, self.version, self.architecture)
+__all__.append('Binary')
+
def get_binary_from_id(id, session=None):
"""
Returns Binary object for given C{id}
@@ -165,6 +182,8 @@ def get_binary_from_id(id, session=None):
return None
return q.one()
+__all__.append('get_binary_from_id')
+
def get_binaries_from_name(package, session=None):
"""
Returns list of Binary objects for given C{package} name
@@ -183,6 +202,8 @@ def get_binaries_from_name(package, session=None):
session = DBConn().session()
return session.query(Binary).filter_by(package=package).all()
+__all__.append('get_binaries_from_name')
+
class Component(object):
def __init__(self, *args, **kwargs):
pass
@@ -190,6 +211,9 @@ class Component(object):
def __repr__(self):
return '<Component %s>' % self.component_name
+
+__all__.append('Component')
+
def get_component(component, session=None):
"""
Returns database id for given C{component}.
@@ -209,6 +233,8 @@ def get_component(component, session=None):
return None
return q.one()
+__all__.append('get_component')
+
class DBConfig(object):
def __init__(self, *args, **kwargs):
pass
@@ -216,6 +242,8 @@ class DBConfig(object):
def __repr__(self):
return '<DBConfig %s>' % self.name
+__all__.append('DBConfig')
+
class ContentFilename(object):
def __init__(self, *args, **kwargs):
pass
@@ -223,6 +251,8 @@ class ContentFilename(object):
def __repr__(self):
return '<ContentFilename %s>' % self.filename
+__all__.append('ContentFilename')
+
class ContentFilepath(object):
def __init__(self, *args, **kwargs):
pass
@@ -230,6 +260,8 @@ class ContentFilepath(object):
def __repr__(self):
return '<ContentFilepath %s>' % self.filepath
+__all__.append('ContentFilepath')
+
class ContentAssociation(object):
def __init__(self, *args, **kwargs):
pass
@@ -237,6 +269,8 @@ class ContentAssociation(object):
def __repr__(self):
return '<ContentAssociation %s>' % self.ca_id
+__all__.append('ContentAssociation')
+
class DSCFile(object):
def __init__(self, *args, **kwargs):
pass
@@ -244,6 +278,8 @@ class DSCFile(object):
def __repr__(self):
return '<DSCFile %s>' % self.dscfile_id
+__all__.append('DSCFile')
+
class PoolFile(object):
def __init__(self, *args, **kwargs):
pass
@@ -251,6 +287,8 @@ class PoolFile(object):
def __repr__(self):
return '<PoolFile %s>' % self.filename
+__all__.append('PoolFile')
+
class Fingerprint(object):
def __init__(self, *args, **kwargs):
pass
@@ -258,6 +296,8 @@ class Fingerprint(object):
def __repr__(self):
return '<Fingerprint %s>' % self.fingerprint
+__all__.append('Fingerprint')
+
class Keyring(object):
def __init__(self, *args, **kwargs):
pass
@@ -265,6 +305,8 @@ class Keyring(object):
def __repr__(self):
return '<Keyring %s>' % self.keyring_name
+__all__.append('Keyring')
+
class Location(object):
def __init__(self, *args, **kwargs):
pass
@@ -272,6 +314,8 @@ class Location(object):
def __repr__(self):
return '<Location %s (%s)>' % (self.path, self.location_id)
+__all__.append('Location')
+
class Maintainer(object):
def __init__(self, *args, **kwargs):
pass
@@ -279,6 +323,8 @@ class Maintainer(object):
def __repr__(self):
return '''<Maintainer '%s' (%s)>''' % (self.name, self.maintainer_id)
+__all__.append('Maintainer')
+
class Override(object):
def __init__(self, *args, **kwargs):
pass
@@ -286,6 +332,8 @@ class Override(object):
def __repr__(self):
return '<Override %s (%s)>' % (self.package, self.suite_id)
+__all__.append('Override')
+
class OverrideType(object):
def __init__(self, *args, **kwargs):
pass
@@ -293,6 +341,8 @@ class OverrideType(object):
def __repr__(self):
return '<OverrideType %s>' % self.overridetype
+__all__.append('OverrideType')
+
def get_override_type(override_type, session=None):
"""
Returns OverrideType object for given C{override type}.
@@ -315,6 +365,8 @@ def get_override_type(override_type, session=None):
return None
return q.one()
+__all__.append('get_override_type')
+
class PendingContentAssociation(object):
def __init__(self, *args, **kwargs):
pass
@@ -322,6 +374,8 @@ class PendingContentAssociation(object):
def __repr__(self):
return '<PendingContentAssociation %s>' % self.pca_id
+__all__.append('PendingContentAssociation')
+
class Priority(object):
def __init__(self, *args, **kwargs):
pass
@@ -329,6 +383,8 @@ class Priority(object):
def __repr__(self):
return '<Priority %s (%s)>' % (self.priority, self.priority_id)
+__all__.append('Priority')
+
def get_priority(priority, session=None):
"""
Returns Priority object for given C{priority name}.
@@ -351,6 +407,8 @@ def get_priority(priority, session=None):
return None
return q.one()
+__all__.append('get_priority')
+
class Queue(object):
def __init__(self, *args, **kwargs):
pass
@@ -358,6 +416,8 @@ class Queue(object):
def __repr__(self):
return '<Queue %s>' % self.queue_name
+__all__.append('Queue')
+
class QueueBuild(object):
def __init__(self, *args, **kwargs):
pass
@@ -365,6 +425,8 @@ class QueueBuild(object):
def __repr__(self):
return '<QueueBuild %s (%s)>' % (self.filename, self.queue_id)
+__all__.append('QueueBuild')
+
class Section(object):
def __init__(self, *args, **kwargs):
pass
@@ -372,6 +434,8 @@ class Section(object):
def __repr__(self):
return '<Section %s>' % self.section
+__all__.append('Section')
+
def get_section(section, session=None):
"""
Returns Section object for given C{section name}.
@@ -394,6 +458,8 @@ def get_section(section, session=None):
return None
return q.one()
+__all__.append('get_section')
+
class Source(object):
def __init__(self, *args, **kwargs):
pass
@@ -401,6 +467,8 @@ class Source(object):
def __repr__(self):
return '<Source %s (%s)>' % (self.source, self.version)
+__all__.append('Source')
+
def get_sources_from_name(source, session=None):
"""
Returns list of Source objects for given C{source} name
@@ -419,6 +487,8 @@ def get_sources_from_name(source, session=None):
session = DBConn().session()
return session.query(Source).filter_by(source=source).all()
+__all__.append('get_sources_from_name')
+
def get_source_in_suite(source, suite, session=None):
"""
Returns list of Source objects for a combination of C{source} and C{suite}.
@@ -446,6 +516,8 @@ def get_source_in_suite(source, suite, session=None):
# ???: Maybe we should just return the SrcAssociation object instead
return q.one().source
+__all__.append('get_source_in_suite')
+
class SrcAssociation(object):
def __init__(self, *args, **kwargs):
pass
@@ -453,6 +525,8 @@ class SrcAssociation(object):
def __repr__(self):
return '<SrcAssociation %s (%s, %s)>' % (self.sa_id, self.source, self.suite)
+__all__.append('SrcAssociation')
+
class SrcUploader(object):
def __init__(self, *args, **kwargs):
pass
@@ -460,6 +534,8 @@ class SrcUploader(object):
def __repr__(self):
return '<SrcUploader %s>' % self.uploader_id
+__all__.append('SrcUploader')
+
class Suite(object):
def __init__(self, *args, **kwargs):
pass
@@ -467,6 +543,8 @@ class Suite(object):
def __repr__(self):
return '<Suite %s>' % self.suite_name
+__all__.append('Suite')
+
def get_suite_architecture(suite, architecture, session=None):
"""
Returns a SuiteArchitecture object given C{suite} and ${arch} or None if it
@@ -496,6 +574,7 @@ def get_suite_architecture(suite, architecture, session=None):
return None
return q.one()
+__all__.append('get_suite_architecture')
def get_suite(suite, session=None):
"""
@@ -519,6 +598,8 @@ def get_suite(suite, session=None):
return None
return q.one()
+__all__.append('get_suite')
+
class SuiteArchitecture(object):
def __init__(self, *args, **kwargs):
pass
@@ -526,6 +607,8 @@ class SuiteArchitecture(object):
def __repr__(self):
return '<SuiteArchitecture (%s, %s)>' % (self.suite_id, self.arch_id)
+__all__.append('SuiteArchitecture')
+
def get_suite_architectures(suite, session=None):
"""
Returns list of Architecture objects for given C{suite} name
@@ -549,6 +632,7 @@ def get_suite_architectures(suite, session=None):
q = q.join(Suite).filter_by(suite_name=suite).order_by('arch_string')
return q.all()
+__all__.append('get_suite_architectures')
class Uid(object):
def __init__(self, *args, **kwargs):
@@ -557,6 +641,8 @@ class Uid(object):
def __repr__(self):
return '<Uid %s (%s)>' % (self.uid, self.name)
+__all__.append('Uid')
+
################################################################################
class DBConn(Singleton):
--
1.5.6.5
Reply to: