[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/bpo] move logic into a function



Signed-off-by: Mark Hymers <mhy@debian.org>
---
 dak/process_accepted.py  |    8 +-------
 dak/process_unchecked.py |    8 +-------
 daklib/utils.py          |   12 ++++++++++++
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/dak/process_accepted.py b/dak/process_accepted.py
index 07d611d..e53a969 100755
--- a/dak/process_accepted.py
+++ b/dak/process_accepted.py
@@ -183,13 +183,7 @@ def init():
         if len(changes_files) > 0:
             utils.warn("Directory provided so ignoring files given on command line")
 
-        dir = Cnf["Dinstall::Options::Directory"]
-        try:
-            # Much of the rest of p-a depends on being in the right place
-            os.chdir(dir)
-            changes_files = [x for x in os.listdir(dir) if x.endswith('.changes')]
-        except OSError, e:
-            utils.fubar("Failed to read list from directory %s (%s)" % (dir, e))
+        changes_files = utils.get_changes_files(Cnf["Dinstall::Options::Directory"])
 
     Upload = queue.Upload(Cnf)
     projectB = Upload.projectB
diff --git a/dak/process_unchecked.py b/dak/process_unchecked.py
index e045726..c2adb63 100755
--- a/dak/process_unchecked.py
+++ b/dak/process_unchecked.py
@@ -98,13 +98,7 @@ def init():
         if len(changes_files) > 0:
             utils.warn("Directory provided so ignoring files given on command line")
 
-        dir = Cnf["Dinstall::Options::Directory"]
-        try:
-            # Much of the rest of p-u depends on being in the right place
-            os.chdir(dir)
-            changes_files = [x for x in os.listdir(dir) if x.endswith('.changes')]
-        except OSError, e:
-            utils.fubar("Failed to read list from directory %s (%s)" % (dir, e))
+        changes_files = utils.get_changes_files(Cnf["Dinstall::Options::Directory"])
 
     Upload = queue.Upload(Cnf)
 
diff --git a/daklib/utils.py b/daklib/utils.py
index e0bdfe8..963abd5 100755
--- a/daklib/utils.py
+++ b/daklib/utils.py
@@ -1498,6 +1498,18 @@ def is_email_alias(email):
 
 ################################################################################
 
+def get_changes_files(dir):
+    try:
+        # Much of the rest of p-u/p-a depends on being in the right place
+        os.chdir(dir)
+        changes_files = [x for x in os.listdir(dir) if x.endswith('.changes')]
+    except OSError, e:
+        fubar("Failed to read list from directory %s (%s)" % (dir, e))
+
+    return changes_files
+
+################################################################################
+
 apt_pkg.init()
 
 Cnf = apt_pkg.newConfiguration()
-- 
1.5.6.5



Reply to: