aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--LICENSE14
-rw-r--r--README.md14
-rwxr-xr-xbin/pepseq60
-rw-r--r--pepseq/__init__.py0
-rw-r--r--pepseq/pepseqconfig.py50
-rw-r--r--setup.py58
7 files changed, 197 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..cd26df3
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Copyright (C) 2010 Jon Bernard <jbernard@tuxion.com>
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..cbfb5e0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,14 @@
+Copyright (C) 2010 Jon Bernard
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c1a6406
--- /dev/null
+++ b/README.md
@@ -0,0 +1,14 @@
+pepseq -- A peptide sequencing application
+==========================================
+
+## DESCRIPTION
+
+pepseq is a...
+
+## INSTALLATION
+
+The best way to install pepseq is...
+
+## RUNNING
+
+To run pepseq, simply...
diff --git a/bin/pepseq b/bin/pepseq
new file mode 100755
index 0000000..ef824fc
--- /dev/null
+++ b/bin/pepseq
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import gettext
+import logging
+import optparse
+import os
+import sys
+
+import gettext
+from gettext import gettext as _
+gettext.textdomain('pepseq')
+
+# Add project root directory (enable symlink, and trunk execution).
+PROJECT_ROOT_DIRECTORY = os.path.abspath(
+ os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))))
+
+if (os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, 'pepseq'))
+ and PROJECT_ROOT_DIRECTORY not in sys.path):
+ sys.path.insert(0, PROJECT_ROOT_DIRECTORY)
+ os.putenv('PYTHONPATH', PROJECT_ROOT_DIRECTORY) # for subprocesses
+
+from pepseq import pepseqconfig
+
+LEVELS = ( logging.ERROR,
+ logging.WARNING,
+ logging.INFO,
+ logging.DEBUG,
+ )
+
+if __name__ == "__main__":
+
+ version = pepseqconfig.__pepseq_data_directory__
+ # Support for command line options.
+ usage = _("pepseq [options]")
+ parser = optparse.OptionParser(version="pepseq %s" % version, usage=usage)
+ parser.add_option('-d', '--debug', dest='debug_mode', action='store_true',
+ help=_('Print the maximum debugging info (implies -vv)'))
+ parser.add_option('-v', '--verbose', dest='logging_level', action='count',
+ help=_('set error_level output to warning, info, and then debug'))
+ # exemple of silly CLI option
+ parser.add_option("-f", "--foo", action="store", dest="foo",
+ help=_("foo should be assigned to bar"))
+ parser.set_defaults(logging_level=0, foo=None)
+ (options, args) = parser.parse_args()
+
+ # set the verbosity
+ if options.debug_mode:
+ options.logging_level = 3
+ logging.basicConfig(level=LEVELS[options.logging_level], format='%(asctime)s %(levelname)s %(message)s')
+
+
+ # this is the easter egg (:
+ if options.foo == 'bar':
+ logging.warning(_('easter egg found'))
+ print(_("Schweet"))
+
+ # Run your cli application there.
+ print _("I'm launched and my args are: %s") % (" ".join(args))
+ logging.debug(_('end of prog'))
diff --git a/pepseq/__init__.py b/pepseq/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/pepseq/__init__.py
diff --git a/pepseq/pepseqconfig.py b/pepseq/pepseqconfig.py
new file mode 100644
index 0000000..a4c18c6
--- /dev/null
+++ b/pepseq/pepseqconfig.py
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+
+__all__ = [
+ 'project_path_not_found',
+ 'get_data_file',
+ 'get_data_path',
+ ]
+
+# Where your project will look for your data (for instance, images and ui
+# files). By default, this is ../data, relative your trunk layout
+__pepseq_data_directory__ = '../data/'
+__license__ = ''
+
+import os
+
+import gettext
+from gettext import gettext as _
+gettext.textdomain('pepseq')
+
+class project_path_not_found(Exception):
+ """Raised when we can't find the project directory."""
+
+
+def get_data_file(*path_segments):
+ """Get the full path to a data file.
+
+ Returns the path to a file underneath the data directory (as defined by
+ `get_data_path`). Equivalent to os.path.join(get_data_path(),
+ *path_segments).
+ """
+ return os.path.join(get_data_path(), *path_segments)
+
+
+def get_data_path():
+ """Retrieve pepseq data path
+
+ This path is by default <pepseq_lib_path>/../data/ in trunk
+ and /usr/share/pepseq in an installed version but this path
+ is specified at installation time.
+ """
+
+ # Get pathname absolute or relative.
+ path = os.path.join(
+ os.path.dirname(__file__), __pepseq_data_directory__)
+
+ abs_data_path = os.path.abspath(path)
+ if not os.path.exists(abs_data_path):
+ raise project_path_not_found
+
+ return abs_data_path
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..a139ea9
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os
+import sys
+
+try:
+ import DistUtilsExtra.auto
+except ImportError:
+ print >> sys.stderr, 'To build pepseq you need https://launchpad.net/python-distutils-extra'
+ sys.exit(1)
+assert DistUtilsExtra.auto.__version__ >= '2.18', 'needs DistUtilsExtra.auto >= 2.18'
+
+def update_data_path(prefix, oldvalue=None):
+
+ try:
+ fin = file('pepseq/pepseqconfig.py', 'r')
+ fout = file(fin.name + '.new', 'w')
+
+ for line in fin:
+ fields = line.split(' = ') # Separate variable from value
+ if fields[0] == '__pepseq_data_directory__':
+ # update to prefix, store oldvalue
+ if not oldvalue:
+ oldvalue = fields[1]
+ line = "%s = '%s'\n" % (fields[0], prefix)
+ else: # restore oldvalue
+ line = "%s = %s" % (fields[0], oldvalue)
+ fout.write(line)
+
+ fout.flush()
+ fout.close()
+ fin.close()
+ os.rename(fout.name, fin.name)
+ except (OSError, IOError), e:
+ print ("ERROR: Can't find pepseq/pepseqconfig.py")
+ sys.exit(1)
+ return oldvalue
+
+
+class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
+ def run(self):
+ previous_value = update_data_path(self.prefix + '/share/pepseq/')
+ DistUtilsExtra.auto.install_auto.run(self)
+ update_data_path(self.prefix, previous_value)
+
+
+
+DistUtilsExtra.auto.setup(
+ name='pepseq',
+ version='0.1',
+ #license='GPL-3',
+ #author='Your Name',
+ #author_email='email@ubuntu.com',
+ #description='UI for managing …',
+ #long_description='Here a longer description',
+ #url='https://launchpad.net/pepseq',
+ cmdclass={'install': InstallAndUpdateDataDirectory})