[Lsb-messages] /var/www/bzr/lsb/devel/repogen r208: Handle lookup errors with pkglists better.
Jeff Licquia
licquia at linuxfoundation.org
Mon Jun 17 22:12:09 UTC 2013
------------------------------------------------------------
revno: 208
committer: Jeff Licquia <licquia at linuxfoundation.org>
branch nick: repogen
timestamp: Mon 2013-06-17 18:12:09 -0400
message:
Handle lookup errors with pkglists better.
- Do the line splitting in lookupPkgList instead of outside it.
- Return a Maybe for the actual list of words representing the project.
modified:
Classifier.hs
-------------- next part --------------
=== modified file 'Classifier.hs'
--- a/Classifier.hs 2013-06-17 19:09:54 +0000
+++ b/Classifier.hs 2013-06-17 22:12:09 +0000
@@ -66,27 +66,33 @@
(S390X, "s390x") ]
-- The project associated with each package is stored in the task-pkgs
--- project, in package/pkglists.
+-- project, in package/pkglists. This function returns the project
+-- information found for the given package name, or Nothing if none was
+-- found.
-lookupPkgList :: String -> IO String
+lookupPkgList :: String -> IO (Maybe [String])
lookupPkgList pkgName = do
pkglist <- openFile "pkglists" ReadMode
pkgLines <- fmap lines $ hGetContents pkglist
- return $ head $ filter (\line -> line =~ pkgName) pkgLines
+ let pkgFoundLines = filter (\line -> line =~ pkgName) pkgLines
+ if null pkgFoundLines then return Nothing
+ else return . Just . words $ head pkgFoundLines
project :: Package -> IO (Maybe PackageProject)
-project pkg
- = (`lookup` projectAssociations) <$>
- (!! 1) <$> (fmap words $ lookupPkgList $ name pkg)
+project pkg = do
+ pInfo <- lookupPkgList $ name pkg
+ return $ join $ fmap (`lookup` projectAssociations) $ liftM (!! 1) pInfo
-- LSB version for a package. Partially derived from the version string
-- of the package, and partially derived from the project data. "Nothing"
--- here means "this package is version-independent".
+-- here means "no LSB-specific version information available" (either the
+-- package is version-independent, or we couldn't find project info).
packageLSBVersion :: Package -> IO (Maybe String)
-packageLSBVersion p =
- let versions = (split ',') <$> (!! 2) <$> (fmap words $ lookupPkgList $ name p)
- in (find (`isPrefixOf` (version p))) <$> versions
+packageLSBVersion p = do
+ pInfo <- lookupPkgList $ name p
+ let versions = liftM (split ',') $ liftM (!! 2) pInfo
+ return $ join $ (find (`isPrefixOf` (version p))) <$> versions
-- The project's status is determined from its path. Specifically,
-- does the path contain "beta", "released-", "snapshots", etc.
More information about the lsb-messages
mailing list