summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-10-21 15:45:21 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-10-21 15:45:21 +0100
commit61e835845955c3653198ffd6a64df7ff0f6a547e (patch)
tree57de2dbc9555cc4bbad3602ea4803cc6a206750e
parent44ee17802dc04b4ecfa7ec812a5a0318bf69c62f (diff)
downloadimport-61e835845955c3653198ffd6a64df7ff0f6a547e.tar.gz
Organise import extensions and data into subdirectories
Finally the repo starts to look a little more tidy!
-rw-r--r--baserockimport/mainloop.py8
-rw-r--r--data/omnibus.yaml (renamed from omnibus.yaml)0
-rw-r--r--data/rubygems.yaml (renamed from rubygems.yaml)0
-rw-r--r--exts/importer_base.py (renamed from importer_base.py)5
-rw-r--r--exts/importer_base.rb (renamed from importer_base.rb)2
-rw-r--r--exts/importer_bundler_extensions.rb (renamed from importer_bundler_extensions.rb)0
-rw-r--r--exts/importer_omnibus_extensions.rb (renamed from importer_omnibus_extensions.rb)0
-rwxr-xr-xexts/omnibus.find_deps (renamed from omnibus.find_deps)0
-rwxr-xr-xexts/omnibus.to_chunk (renamed from omnibus.to_chunk)0
-rwxr-xr-xexts/omnibus.to_lorry (renamed from omnibus.to_lorry)0
-rwxr-xr-xexts/rubygems.find_deps (renamed from rubygems.find_deps)0
-rwxr-xr-xexts/rubygems.to_chunk (renamed from rubygems.to_chunk)0
-rwxr-xr-xexts/rubygems.to_lorry (renamed from rubygems.to_lorry)2
13 files changed, 12 insertions, 5 deletions
diff --git a/baserockimport/mainloop.py b/baserockimport/mainloop.py
index c081be5..35f4b4d 100644
--- a/baserockimport/mainloop.py
+++ b/baserockimport/mainloop.py
@@ -82,9 +82,11 @@ def run_extension(filename, args, cwd='.'):
report_logger=report_extension_logger,
)
- # There are better ways of doing this, but it works for now.
- main_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
- extension_path = os.path.join(main_path, filename)
+ def extensions_dir():
+ module_dir = os.path.dirname(baserockimport.__file__)
+ return os.path.join(module_dir, '..', 'exts')
+
+ extension_path = os.path.join(extensions_dir(), filename)
logging.debug("Running %s %s with cwd %s" % (extension_path, args, cwd))
returncode = ext.run(extension_path, args, cwd, os.environ)
diff --git a/omnibus.yaml b/data/omnibus.yaml
index 2116f2a..2116f2a 100644
--- a/omnibus.yaml
+++ b/data/omnibus.yaml
diff --git a/rubygems.yaml b/data/rubygems.yaml
index e1e6fcc..e1e6fcc 100644
--- a/rubygems.yaml
+++ b/data/rubygems.yaml
diff --git a/importer_base.py b/exts/importer_base.py
index 5def0dc..5e75f65 100644
--- a/importer_base.py
+++ b/exts/importer_base.py
@@ -64,6 +64,11 @@ class ImportExtension(object):
def process_args(self, args):
raise NotImplementedError()
+ def local_data_path(self, filename):
+ '''Return path to 'file' inside the package data/ directory. '''
+ script_dir = os.path.dirname(os.path.realpath(__file__))
+ return os.path.join(script_dir, '..', 'data', filename)
+
def run(self):
try:
self.process_args(sys.argv[1:])
diff --git a/importer_base.rb b/exts/importer_base.rb
index b16b436..98eb05c 100644
--- a/importer_base.rb
+++ b/exts/importer_base.rb
@@ -51,7 +51,7 @@ module Importer
# Return the path to 'file' relative to the currently running program.
# Used as a simple mechanism of finding local data files.
script_dir = File.dirname(__FILE__)
- File.join(script_dir, file)
+ File.join(script_dir, '..', 'data', file)
end
def write_lorry(file, lorry)
diff --git a/importer_bundler_extensions.rb b/exts/importer_bundler_extensions.rb
index 034b3c2..034b3c2 100644
--- a/importer_bundler_extensions.rb
+++ b/exts/importer_bundler_extensions.rb
diff --git a/importer_omnibus_extensions.rb b/exts/importer_omnibus_extensions.rb
index 2286d35..2286d35 100644
--- a/importer_omnibus_extensions.rb
+++ b/exts/importer_omnibus_extensions.rb
diff --git a/omnibus.find_deps b/exts/omnibus.find_deps
index 8fea31d..8fea31d 100755
--- a/omnibus.find_deps
+++ b/exts/omnibus.find_deps
diff --git a/omnibus.to_chunk b/exts/omnibus.to_chunk
index 5e527a9..5e527a9 100755
--- a/omnibus.to_chunk
+++ b/exts/omnibus.to_chunk
diff --git a/omnibus.to_lorry b/exts/omnibus.to_lorry
index 256f924..256f924 100755
--- a/omnibus.to_lorry
+++ b/exts/omnibus.to_lorry
diff --git a/rubygems.find_deps b/exts/rubygems.find_deps
index 228c88b..228c88b 100755
--- a/rubygems.find_deps
+++ b/exts/rubygems.find_deps
diff --git a/rubygems.to_chunk b/exts/rubygems.to_chunk
index c1a3e7c..c1a3e7c 100755
--- a/rubygems.to_chunk
+++ b/exts/rubygems.to_chunk
diff --git a/rubygems.to_lorry b/exts/rubygems.to_lorry
index 7a00820..564adc9 100755
--- a/rubygems.to_lorry
+++ b/exts/rubygems.to_lorry
@@ -66,7 +66,7 @@ class RubyGemLorryGenerator(ImportExtension):
def __init__(self):
super(RubyGemLorryGenerator, self).__init__()
- with open('rubygems.yaml', 'r') as f:
+ with open(self.local_data_path('rubygems.yaml'), 'r') as f:
local_data = yaml.load(f.read())
self.lorry_prefix = local_data['lorry-prefix']