patterns is a sequence of glob-patterns for the files you want to copy. """ if glob.has_magic(source) or glob.has_magic(target): raise ValueError("Magic not allowed in src, target") ret = {} for pattern in patterns: pattern = os.path.join(source,pattern) for filename in glob.glob(pattern): if os.path.isfile(filename): targetpath = os.path.join(target,os.path.relpath(filename,source)) path = os.path.dirname(targetpath) ret.setdefault(path,[]).append(filename) return sorted(ret.items()) check_environment() package_args = dict( name='medin-metadata', version=__version__, description='Tool to extract MEDIN XML metadata from a DAC RDBMS and optionally validate it', author='Homme Zwaagstra', author_email='*****@*****.**', url='http://www.geodata.soton.ac.uk', requires=['libxml2', 'libxslt', 'suds', 'sqlalchemy'], packages=['medin', 'medin.schema'], package_data={'medin': ['data/isotc211/*.txt', 'data/isotc211/gco/*', 'data/isotc211/gfc/*', 'data/isotc211/gmd/*', 'data/isotc211/gmi/*',
def main(): """ The main program """ from optparse import OptionParser # try and load the medin modules try: import medin from medin import log from medin.util import check_environment from medin.output import MIMEOutput, FileOutput, DirOutput, ValidationWarning, FilterXMLDoc except ImportError: die('The medin module could not be found. Please ensure it is in your python module search path.') # parse out the command options usage = """usage: %prog [OPTION]... [INPUT]... Check MEDIN XML files to see whether they conform to the MEDIN metadata schema. Basic Usage: INPUT is the XML input to examine. It can be an individual file, a directory or a URL, and may be specified more than once. If INPUT is not specified, or is `-`, then the XML is read from standard input. When a directory is specified, xml files to be validated are expected to have a `.xml` extension. Validation is a three step process: 1. Validate against the ISO TC 211 W3C schema. 2. Validate against the ISO TS 19139 A1 Constraints (version 1.3) 3. Validate against the Medin Metadata Profile (version 1.7) Any XML document passing these tests complies with the Medin Metadata requirements.""" parser = OptionParser(usage=usage, version="%%prog %s" % str(__version__)) # add the command line options parser.add_option("-d", '--debug', action="store_true", help="Enable debugging output") parser.add_option("-n", '--no-mime', action="store_true", help="Do not encapsulate the XML output in MIME format. This is only useful when --destination is not specified.") parser.add_option("-r", '--recurse', action="store_true", help="If INPUT is a directory, recurse into subdirectories as well") parser.add_option("-o", '--destination', metavar='DIRECTORY', help="Output the XML to the specified DIRECTORY. Existing files are over-written.") parser.add_option("-v", '--validation', default='strict', metavar='LEVEL', choices=['warn', 'strict'], help="""Control validation of output XML. LEVEL can be either 'warn' (output warning messages for failed validations) or 'strict' (default - output a warning message for a failed validation and exit the program)""") (options, args) = parser.parse_args() inputs = set(args) if not inputs: inputs = ['-'] # default to STDIN # turn on debugging global DEBUG if options.debug: DEBUG = medin.DEBUG = True try: check_environment(True) # only check the XML support except EnvironmentError, e: die(str(e))