コード例 #1
0
 def _cleanup_image_files(
     self,
     directory,
     tmp_directory,
     image_count,
     image_prefix,
     image_format,
     ):
     from abjad.tools import systemtools
     image_directory = os.path.join(directory, 'images')
     if not os.path.isdir(image_directory):
         os.mkdir(image_directory)
     for x in os.listdir(tmp_directory):
         if x.endswith('.png'):
             source = os.path.join(tmp_directory, x)
             target = os.path.join(image_directory, x)
             if not os.path.exists(target) or \
                 not documentationtools.compare_images(source, target):
                 os.rename(source, target)
                 if self.verbose:
                     print('\tMoving {}.'.format(x))
             else:
                 if self.verbose:
                     print('\tKeeping old {}.'.format(x))
         elif x.endswith('.pdf'):
             source = os.path.join(tmp_directory, x)
             target = os.path.join(image_directory, x)
             if systemtools.TestManager.compare_files(source, target):
                 if self.verbose:
                     print('\tKeeping old {}.'.format(x))
                 continue
             os.rename(source, target)
             if self.verbose:
                 print('\tMoving {}.'.format(x))
コード例 #2
0
ファイル: AbjadBookProcessor.py プロジェクト: willingc/abjad
 def _cleanup_image_files(self, directory, tmp_directory,
     image_count, image_prefix, image_format):
     #print 'CLEANUP IMAGE FILES'
     image_directory = os.path.join(directory, 'images')
     if not os.path.isdir(image_directory):
         os.mkdir(image_directory)
     # remove old images
     #for x in os.listdir(image_directory):
     #    if x.startswith('{}-'.format(image_prefix)) and \
     #        x.endswith(image_format):
     #        # this should handle both 'index-1.png' and 'index-1-page3.png'
     #        name = os.path.splitext(x)[0]
     #        number = int(name.split('-')[1])
     #        if image_count < number:
     #            os.remove(os.path.join(image_directory, x))
     for x in os.listdir(tmp_directory):
         if x.endswith('.png'):
             source = os.path.join(tmp_directory, x)
             target = os.path.join(image_directory, x)
             if not os.path.exists(target) or \
                 not documentationtools.compare_images(source, target):
                 os.rename(source, target)
                 if self.verbose:
                     print '\tMoving {}.'.format(x)
             else:
                 if self.verbose:
                     print '\tKeeping old {}.'.format(x)
         elif x.endswith('.pdf'):
             source = os.path.join(tmp_directory, x)
             target = os.path.join(image_directory, x)
             os.rename(source, target)
             if self.verbose:
                 print '\tMoving {}.'.format(x)
コード例 #3
0
 def _cleanup_image_files(self, directory, tmp_directory, image_count,
                          image_prefix, image_format):
     #print 'CLEANUP IMAGE FILES'
     image_directory = os.path.join(directory, 'images')
     if not os.path.isdir(image_directory):
         os.mkdir(image_directory)
     # remove old images
     #for x in os.listdir(image_directory):
     #    if x.startswith('{}-'.format(image_prefix)) and \
     #        x.endswith(image_format):
     #        # this should handle both 'index-1.png' and 'index-1-page3.png'
     #        name = os.path.splitext(x)[0]
     #        number = int(name.split('-')[1])
     #        if image_count < number:
     #            os.remove(os.path.join(image_directory, x))
     for x in os.listdir(tmp_directory):
         if x.endswith('.png'):
             source = os.path.join(tmp_directory, x)
             target = os.path.join(image_directory, x)
             if not os.path.exists(target) or \
                 not documentationtools.compare_images(source, target):
                 os.rename(source, target)
                 if self.verbose:
                     print('\tMoving {}.'.format(x))
             else:
                 if self.verbose:
                     print('\tKeeping old {}.'.format(x))
         elif x.endswith('.pdf'):
             source = os.path.join(tmp_directory, x)
             target = os.path.join(image_directory, x)
             os.rename(source, target)
             if self.verbose:
                 print('\tMoving {}.'.format(x))