|
|
4c79b5 |
# framework - The CentOS Artwork Repository framework structure.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# Copyright (C) 2009-2010 Alain Reguera Delgado
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# This program is free software; you can redistribute it and/or modify
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# General Public License for more details.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# along with this program; if not, write to the Free Software
|
|
|
4c79b5 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
4c79b5 |
# USA.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
#------------------------------------------------------------
|
|
|
4c79b5 |
# $Id: framework.py 6045 2010-07-13 08:11:03Z al $
|
|
|
4c79b5 |
#-----------------------------------------------------------
|
|
|
4c79b5 |
"""
|
|
|
4c79b5 |
The CentOS Artwork Repository framework structure.
|
|
|
4c79b5 |
|
|
|
4c79b5 |
"""
|
|
|
4c79b5 |
|
|
|
4c79b5 |
import string
|
|
|
4c79b5 |
import os
|
|
|
4c79b5 |
import re
|
|
|
4c79b5 |
|
|
|
4c79b5 |
from repository import Repo
|
|
|
4c79b5 |
|
|
|
4c79b5 |
class Framework:
|
|
|
4c79b5 |
"""
|
|
|
4c79b5 |
This structure provides attributes and methods needed by CentOS
|
|
|
4c79b5 |
artwork repository framework structures.
|
|
|
4c79b5 |
"""
|
|
|
4c79b5 |
|
|
|
4c79b5 |
def __init__(self):
|
|
|
4c79b5 |
self.fw = {}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
def find(self,id):
|
|
|
4c79b5 |
"""
|
|
|
4c79b5 |
Return a dictionary object containing information about
|
|
|
4c79b5 |
frameworks. This function explores the repository structure
|
|
|
4c79b5 |
looking for framework directories. Framework directories are
|
|
|
4c79b5 |
defined as regular directories containing at least the
|
|
|
4c79b5 |
subdirectory `tpl/' in its first level.
|
|
|
4c79b5 |
"""
|
|
|
4c79b5 |
repo = Repo()
|
|
|
4c79b5 |
rootdir = str(repo.abspath + repo.workline[0])
|
|
|
4c79b5 |
template = re.compile('^.*/tpl/?$')
|
|
|
4c79b5 |
for root, dirs, files in os.walk(rootdir):
|
|
|
4c79b5 |
if id in root and template.match(root):
|
|
|
4c79b5 |
print root
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
def getPathId(self, path):
|
|
|
4c79b5 |
"""
|
|
|
4c79b5 |
Return the framework's path id by cleaning up its string path.
|
|
|
4c79b5 |
"""
|
|
|
4c79b5 |
# Remove absolute path and workline from string path.
|
|
|
4c79b5 |
# Remove theme directory from string path.
|
|
|
4c79b5 |
# Remove template directory from string path.
|
|
|
4c79b5 |
pass
|
|
|
4c79b5 |
|
|
|
4c79b5 |
def add(self, pathid):
|
|
|
4c79b5 |
"""
|
|
|
4c79b5 |
Return the framework's templates, translations and manuals paths.
|
|
|
4c79b5 |
"""
|
|
|
4c79b5 |
templates = str('trunk/' + pathid + '/tpl')
|
|
|
4c79b5 |
translations = str('trunk/Translations/' + pathid)
|
|
|
4c79b5 |
manuals = str('trunk/Manuals/' + pathid)
|
|
|
4c79b5 |
return (templates, translations, manuals)
|
|
|
4c79b5 |
|
|
|
4c79b5 |
def list(self, id):
|
|
|
4c79b5 |
"""
|
|
|
4c79b5 |
Print available frameworks and its paths.
|
|
|
4c79b5 |
"""
|
|
|
4c79b5 |
self.find(id)
|
|
|
4c79b5 |
for k, v in self.fw.iteritems():
|
|
|
4c79b5 |
pathid = k
|
|
|
4c79b5 |
templates, translations, manuals = v
|
|
|
4c79b5 |
print '%12s: %s' % ('Id', pathid)
|
|
|
4c79b5 |
print '%12s: %s' % ('Templates', templates)
|
|
|
4c79b5 |
print '%12s: %s' % ('Translations', translations)
|
|
|
4c79b5 |
print '%12s: %s' % ('Manuals', manuals)
|
|
|
4c79b5 |
print '-'*66
|