[Gelistirici] [Fwd: trunk/pisi/pisi - Add new option to pisi ar : --ignore-check]

Ozan Çağlayan ozan at pardus.org.tr
14 Ara 2009 Pzt 14:14:22 EET


Bir kaç bişey:


Modified: trunk/pisi/pisi/cli/addrepo.py
=================================================================
--- trunk/pisi/pisi/cli/addrepo.py	(original)
+++ trunk/pisi/pisi/cli/addrepo.py	Mon Dec 14 13:55:00 2009
@@ -45,6 +45,9 @@
         group.add_option("--at", action="store",
                                type="int", default=None,
                                help=_("Add repository at given position (0 is first)"))
+        group.add_option("--ignore-check", action="store_true", 
+                               default=False, 
+                               help=_("Ignore distribution release and architecture checks"))
         self.parser.add_option_group(group)

######## "Skip distribution release and architecture check" daha düzgün bence.

 
     def run(self):

Modified: trunk/pisi/pisi/index.py
=================================================================
--- trunk/pisi/pisi/index.py	(original)
+++ trunk/pisi/pisi/index.py	Mon Dec 14 13:55:00 2009
@@ -34,6 +34,16 @@
 class Error(pisi.Error):
     pass
 
+class NotCompatibleDistroException(pisi.Exception):
+    def __init__(self, repoVersion, curDistro, curDistVersion):
+        pisi.Exception.__init__(self, "Opps, sorry, this repository for %s is not compatible with your distribution release %s %s." \
+                % (repoVersion, curDistro, curDistVersion))
+
+class NotCompatibleArchException(pisi.Exception):
+    def __init__(self, repoArch, curArch):
+        pisi.Exception.__init__(self, "Opps, sorry, repo architecture %s is not compatible with your %s architecture." \
+                % (repoArch, curArch))


##### Exception isimleri şöyle olsa?
DistributionMismatchException
ArchitectureMismatchException

distro ve arch gibi kısaltmaya gerek yok bence.

###### Bir de Exception mesajlarında oops'a sorry'ye falan gerek yok bence:
The repository couldn't be added because of distribution release mismatch.
The repository couldn't ve added because of distribution architecture mismatch.

 
+    def check_distro_and_arch(self, doc):
+        config = pisi.configfile.ConfigurationFile("/etc/pisi/pisi.conf")
+        if doc.getTag("Distribution").getTagData("Version") != config.get("general", "distribution_release"):
+            raise NotCompatibleDistroException(doc.getTag("Distribution").getTagData("Version"), \
+                    config.get("general", "distribution"), config.get("general", "distribution_release"))
+        if doc.getTag("Distribution").getTagData("Architecture"):
+            # First check if Architecture tag exists in index.xml; if not, directly skip it  ;) 
+            if doc.getTag("Distribution").getTagData("Architecture") != config.get("general", "architecture"):
+                raise NotCompatibleArchException(doc.getTag("Distribution").getTagData("Architecture"), \
+                    config.get("general", "architecture"))


check_distribution_and_architecture() şeklinde uzun olarak yazarsak daha düzgün bence.

config nesnesi zaten o esnada bir yerde olabilir (büyük ihtimalle hatta). tekrar yaratman gerekmeyebilir.
# First check if architecture tag....

yorumu da ikinci if'in üstüne gelmeli. 





Gelistirici mesaj listesiyle ilgili daha fazla bilgi