Пример #1
0
class manifest_maker(sdist):

    template = "MANIFEST.in"

    def initialize_options (self):
        self.use_defaults = 1
        self.prune = 1
        self.manifest_only = 1
        self.force_manifest = 1

    def finalize_options(self):
        pass

    def run(self):
        self.filelist = FileList()
        if not os.path.exists(self.manifest):
            self.write_manifest()   # it must exist so it'll get in the list
        self.filelist.findall()
        self.add_defaults()
        if os.path.exists(self.template):
            self.read_template()
        self.prune_file_list()
        self.filelist.sort()
        self.filelist.remove_duplicates()
        self.write_manifest()

    def write_manifest (self):
        """Write the file list in 'self.filelist' (presumably as filled in
        by 'add_defaults()' and 'read_template()') to the manifest file
        named by 'self.manifest'.
        """
        files = self.filelist.files
        if os.sep!='/':
            files = [f.replace(os.sep,'/') for f in files]
        self.execute(write_file, (self.manifest, files),
                     "writing manifest file '{0!s}'".format(self.manifest))

    def warn(self, msg):    # suppress missing-file warnings from sdist
        if not msg.startswith("standard file not found:"):
            sdist.warn(self, msg)

    def add_defaults(self):
        sdist.add_defaults(self)
        self.filelist.append(self.template)
        self.filelist.append(self.manifest)
        rcfiles = list(walk_revctrl())
        if rcfiles:
            self.filelist.extend(rcfiles)
        elif os.path.exists(self.manifest):
            self.read_manifest()
        ei_cmd = self.get_finalized_command('egg_info')
        self.filelist.include_pattern("*", prefix=ei_cmd.egg_info)

    def prune_file_list (self):
        build = self.get_finalized_command('build')
        base_dir = self.distribution.get_fullname()
        self.filelist.exclude_pattern(None, prefix=build.build_base)
        self.filelist.exclude_pattern(None, prefix=base_dir)
        sep = re.escape(os.sep)
        self.filelist.exclude_pattern(sep+r'(RCS|CVS|\.svn)'+sep, is_regex=1)
class manifest_maker(sdist):

    template = "MANIFEST.in"

    def initialize_options (self):
        self.use_defaults = 1
        self.prune = 1
        self.manifest_only = 1
        self.force_manifest = 1

    def finalize_options(self):
        pass

    def run(self):
        self.filelist = FileList()
        if not os.path.exists(self.manifest):
            self.write_manifest()   # it must exist so it'll get in the list
        self.filelist.findall()
        self.add_defaults()
        if os.path.exists(self.template):
            self.read_template()
        self.prune_file_list()
        self.filelist.sort()
        self.filelist.remove_duplicates()
        self.write_manifest()

    def write_manifest (self):
        """Write the file list in 'self.filelist' (presumably as filled in
        by 'add_defaults()' and 'read_template()') to the manifest file
        named by 'self.manifest'.
        """
        files = self.filelist.files
        if os.sep!='/':
            files = [f.replace(os.sep,'/') for f in files]
        self.execute(write_file, (self.manifest, files),
                     "writing manifest file '%s'" % self.manifest)

    def warn(self, msg):    # suppress missing-file warnings from sdist
        if not msg.startswith("standard file not found:"):
            sdist.warn(self, msg)

    def add_defaults(self):
        sdist.add_defaults(self)
        self.filelist.append(self.template)
        self.filelist.append(self.manifest)
        rcfiles = list(walk_revctrl())
        if rcfiles:
            self.filelist.extend(rcfiles)
        elif os.path.exists(self.manifest):
            self.read_manifest()
        ei_cmd = self.get_finalized_command('egg_info')
        self.filelist.include_pattern("*", prefix=ei_cmd.egg_info)

    def prune_file_list (self):
        build = self.get_finalized_command('build')
        base_dir = self.distribution.get_fullname()
        self.filelist.exclude_pattern(None, prefix=build.build_base)
        self.filelist.exclude_pattern(None, prefix=base_dir)
        sep = re.escape(os.sep)
        self.filelist.exclude_pattern(sep+r'(RCS|CVS|\.svn)'+sep, is_regex=1)
Пример #3
0
    def run(self):
        from distutils import log
        from distutils.filelist import FileList
        global CLEANUP

        distutils.command.clean.clean.run(self)

        if self.all:
            fl = FileList()
            fl.include_pattern("*.pyc", 0)
            fl.include_pattern("*.pyd", 0)
            fl.include_pattern("*.so", 0)
            CLEANUP += fl.files

        for f in CLEANUP:
            if os.path.isdir(f):
                try:
                    if not self.dry_run and os.path.exists(f):
                        os.rmdir(f)
                    log.info("removing '%s'", f)
                except IOError:
                    log.warning("unable to remove '%s'", f)

            else:
                try:
                    if not self.dry_run and os.path.exists(f):
                        os.remove(f)
                    log.info("removing '%s'", f)
                except IOError:
                    log.warning("unable to remove '%s'", f)
Пример #4
0
    def run(self):
        from distutils import log
        from distutils.filelist import FileList
        global CLEANUP

        distutils.command.clean.clean.run(self)

        if self.all:
            fl = FileList()
            fl.include_pattern("*.pyc", 0)
            fl.include_pattern("*.pyd", 0)
            fl.include_pattern("*.so", 0)
            CLEANUP += fl.files

        for f in CLEANUP:
            if os.path.isdir(f):
                try:
                    if not self.dry_run and os.path.exists(f):
                        os.rmdir(f)
                    log.info("removing '%s'", f)
                except IOError:
                    log.warning("unable to remove '%s'", f)

            else:
                try:
                    if not self.dry_run and os.path.exists(f):
                        os.remove(f)
                    log.info("removing '%s'", f)
                except IOError:
                    log.warning("unable to remove '%s'", f)
Пример #5
0
 def get_files(pattern):
     filelist = FileList()
     if '**' in pattern:
         pattern = pattern.replace('**', '*')
         anchor = False
     else:
         anchor = True
     filelist.include_pattern(pattern, anchor)
     return filelist.files
Пример #6
0
 def get_files(pattern):
     filelist = FileList()
     if "**" in pattern:
         pattern = pattern.replace("**", "*")
         anchor = False
     else:
         anchor = True
     filelist.include_pattern(pattern, anchor)
     return filelist.files
Пример #7
0
 def get_files(pattern):
     filelist = FileList()
     if '**' in pattern:
         pattern = pattern.replace('**', '*')
         anchor = False
     else:
         anchor = True
     filelist.include_pattern(pattern, anchor)
     return filelist.files
Пример #8
0
 def test_include_pattern(self):
     file_list = FileList()
     file_list.set_allfiles([])
     self.assertFalse(file_list.include_pattern("*.py"))
     file_list = FileList()
     file_list.set_allfiles(["a.py", "b.txt"])
     self.assertTrue(file_list.include_pattern("*.py"))
     file_list = FileList()
     self.assertIsNone(file_list.allfiles)
     file_list.set_allfiles(["a.py", "b.txt"])
     file_list.include_pattern("*")
     self.assertEqual(file_list.allfiles, ["a.py", "b.txt"])
Пример #9
0
 def test_include_pattern(self):
     file_list = FileList()
     file_list.set_allfiles([])
     self.assertFalse(file_list.include_pattern('*.py'))
     file_list = FileList()
     file_list.set_allfiles(['a.py', 'b.txt'])
     self.assertTrue(file_list.include_pattern('*.py'))
     file_list = FileList()
     self.assertIsNone(file_list.allfiles)
     file_list.set_allfiles(['a.py', 'b.txt'])
     file_list.include_pattern('*')
     self.assertEqual(file_list.allfiles, ['a.py', 'b.txt'])
Пример #10
0
def get_files(pattern):
    """
    Retrieve all files in the current directory by a pattern.
    Use ** as greedy wildcard and * as non-greedy wildcard.

    :param pattern: The pattern as used by :obj:`distutils.filelist.Filelist`
    """
    filelist = FileList()
    if '**' in pattern:
        pattern = pattern.replace('**', '*')
        anchor = False
    else:
        anchor = True
    filelist.include_pattern(pattern, anchor)
    return filelist.files
Пример #11
0
def get_files(pattern):
    """
    Retrieve all files in the current directory by a pattern.
    Use ** as greedy wildcard and * as non-greedy wildcard.

    :param pattern: The pattern as used by :obj:`distutils.filelist.Filelist`
    """
    filelist = FileList()
    if '**' in pattern:
        pattern = pattern.replace('**', '*')
        anchor = False
    else:
        anchor = True
    filelist.include_pattern(pattern, anchor)
    return filelist.files
Пример #12
0
    def test_include_pattern(self):
        # return False if no match
        file_list = FileList()
        file_list.set_allfiles([])
        self.assertFalse(file_list.include_pattern('*.py'))

        # return True if files match
        file_list = FileList()
        file_list.set_allfiles(['a.py', 'b.txt'])
        self.assertTrue(file_list.include_pattern('*.py'))

        # test * matches all files
        file_list = FileList()
        self.assertIsNone(file_list.allfiles)
        file_list.set_allfiles(['a.py', 'b.txt'])
        file_list.include_pattern('*')
        self.assertEqual(file_list.allfiles, ['a.py', 'b.txt'])
Пример #13
0
    def test_include_pattern(self):
        # return False if no match
        file_list = FileList()
        file_list.set_allfiles([])
        self.assertFalse(file_list.include_pattern('*.py'))

        # return True if files match
        file_list = FileList()
        file_list.set_allfiles(['a.py', 'b.txt'])
        self.assertTrue(file_list.include_pattern('*.py'))

        # test * matches all files
        file_list = FileList()
        self.assertIsNone(file_list.allfiles)
        file_list.set_allfiles(['a.py', 'b.txt'])
        file_list.include_pattern('*')
        self.assertEqual(file_list.allfiles, ['a.py', 'b.txt'])
	def process_templates(self, target):

		# Build list of files to be processed.
		filelist = FileList()
		if filelist.include_pattern('*.dist_template', anchor=0) == 0:
			# Nothing to do.
			return

		# FIXME: For compatibility with old packages not yet using the version
		# module. Change to unconditional import in gnue-common 0.8.
		try:
			from src import version
		except:
			return

		# List of keywords to replace.
		keywords = {
			':PACKAGE:': self.distribution.get_name(),
			':TITLE:': self.distribution.get_description(),
			':VERSION:': self.distribution.get_version(),
			':MAJOR:': str(version.major),
			':MINOR:': str(version.minor),
			':PHASE:': str(version.phase),
			':BUILD:': str(version.build),
			':SVN:': str(version.svn),
			':DATE_ISO:': time.strftime('%Y-%m-%d', time.gmtime()),
			':DATE_RFC:': time.strftime('%a, %d %b %Y', time.gmtime()),
			':TIME:': time.strftime('%H:%M:%S', time.gmtime())}
		# Hack for version numbering schemes that are limited to x.y.z.
		if version.phase == 'final':
			keywords[':FINAL:'] = str(version.build)
		else:
			keywords[':FINAL:'] = '0'

		for src in filelist.files:
			dst = os.path.join(target, src[:-14])
			args = (src, dst, keywords)
			self.execute(self.__process_template, args,
				"generating %s from %s" % (dst, src))
Пример #15
0
long_description = """\
tel is a little console-based phone book program. It allows adding,
modifing, editing and searching of phone book entries right on your
terminal. Pretty printing capabilites are also provided.
Entries are stored in simple csv file. This eases import and export with
common spread sheet applications like Microsoft Excel or OpenOffice.org
Calc."""

# gettext source file for i18n
optparse_source = optparse.__file__.rstrip('c')

# collect all python sources for i18n
tel_sources = FileList()
tel_sources.findall('./src')
tel_sources.include_pattern('*.py', anchor=False)

setup(
    name='tel',
    version=config.version,
    description='A little terminal phone book',
    long_description=long_description,
    author='Sebastian Wiesner',
    author_email='*****@*****.**',
    url='http://tel.lunaryorn.de',
    license='MIT/X11',
    # list packages
    packages=['tel'],
    package_dir={'': 'src'},
    package_data={'tel': ['backends/*.py']},
    # scripts
Пример #16
0
			if not path: path = os.curdir
			if options.recursive:
				##print ">> findall"
				filelist.findall(path)
				# replace 'file.ext' to './file.ext'
				# we will matching with '*/wildcard.ext'
				for i in range(len(filelist.allfiles)):
					__file = filelist.allfiles[i]
					if not os.path.isabs(__file):   # if not full path, windows or unixx
						filelist.allfiles[i] = '.' + os.sep + __file
			else:
				##print ">> list", list_files(path)
				filelist.set_allfiles(list_files(path))
			##print ">> all files", filelist.allfiles
			##print ">> pattern", file
			filelist.include_pattern(file, anchor=0)
			##print ">> final list", filelist.files

			for file in filelist.files:
				pass_file(file, eater)

	# write the output
	if options.outfile == '-':
		fp = sys.stdout
		closep = 0
	else:
		if options.outpath:
			options.outfile = os.path.join(options.outpath, options.outfile)
		#@Oleg + join - existing option
		if options.joinexisting:
			if os.path.exists(options.outfile): # if file not exist, -j has no efect
Пример #17
0
 def include_pattern (self, pattern,
                      anchor=1, prefix=None, is_regex=0):
     if prefix:
         prefix = os.path.join(self.srcdir, prefix)
     return _FileList.include_pattern(self, pattern, anchor, prefix, is_regex)
Пример #18
0
long_description = """\
tel is a little console-based phone book program. It allows adding,
modifing, editing and searching of phone book entries right on your
terminal. Pretty printing capabilites are also provided.
Entries are stored in simple csv file. This eases import and export with
common spread sheet applications like Microsoft Excel or OpenOffice.org
Calc."""


# gettext source file for i18n
optparse_source = optparse.__file__.rstrip('c')

# collect all python sources for i18n
tel_sources = FileList()
tel_sources.findall('./src')
tel_sources.include_pattern('*.py', anchor=False)


setup(name='tel',
      version=config.version,
      description='A little terminal phone book',
      long_description=long_description,
      author='Sebastian Wiesner',
      author_email='*****@*****.**',
      url='http://tel.lunaryorn.de',
      license='MIT/X11',
      # list packages
      packages=['tel'],
      package_dir={'': 'src'},
      package_data={'tel': ['backends/*.py']},
      # scripts
Пример #19
0
 def include_pattern(self, pattern, anchor=1, prefix=None, is_regex=0):
     if prefix:
         prefix = os.path.join(self.srcdir, prefix)
     return _FileList.include_pattern(self, pattern, anchor, prefix,
                                      is_regex)