comparison mxtool/mx.py @ 18601:676f1800077c

mx: removed unused _read_projects_file function
author Doug Simon <doug.simon@oracle.com>
date Wed, 03 Dec 2014 16:02:36 +0100
parents e97e1f07a3d6
children 7d8270532cd9
comparison
equal deleted inserted replaced
18600:f6ca61099649 18601:676f1800077c
41 import hashlib 41 import hashlib
42 import xml.parsers.expat 42 import xml.parsers.expat
43 import shutil, re, xml.dom.minidom 43 import shutil, re, xml.dom.minidom
44 import pipes 44 import pipes
45 import difflib 45 import difflib
46 from collections import Callable, OrderedDict 46 from collections import Callable
47 from threading import Thread 47 from threading import Thread
48 from argparse import ArgumentParser, REMAINDER 48 from argparse import ArgumentParser, REMAINDER
49 from os.path import join, basename, dirname, exists, getmtime, isabs, expandvars, isdir, isfile 49 from os.path import join, basename, dirname, exists, getmtime, isabs, expandvars, isdir, isfile
50 50
51 _projects = dict() 51 _projects = dict()
785 except subprocess.CalledProcessError: 785 except subprocess.CalledProcessError:
786 if abortOnError: 786 if abortOnError:
787 abort('failed to get status') 787 abort('failed to get status')
788 else: 788 else:
789 return None 789 return None
790
791 # TODO: remove this function once all repos have transitioned
792 # to the new project format
793 def _read_projects_file(projectsFile):
794 suite = OrderedDict()
795
796 suite['projects'] = OrderedDict()
797 suite['libraries'] = OrderedDict()
798 suite['jrelibraries'] = OrderedDict()
799 suite['distributions'] = OrderedDict()
800
801 with open(projectsFile) as f:
802 prefix = ''
803 lineNum = 0
804
805 def error(message):
806 abort(projectsFile + ':' + str(lineNum) + ': ' + message)
807
808 for line in f:
809 lineNum = lineNum + 1
810 line = line.strip()
811 if line.endswith('\\'):
812 prefix = prefix + line[:-1]
813 continue
814 if len(prefix) != 0:
815 line = prefix + line
816 prefix = ''
817 if len(line) != 0 and line[0] != '#':
818 if '=' not in line:
819 error('non-comment line does not contain an "=" character')
820 key, value = line.split('=', 1)
821
822 parts = key.split('@')
823
824 if len(parts) == 1:
825 if parts[0] == 'suite':
826 suite['name'] = value
827 elif parts[0] == 'mxversion':
828 suite['mxversion'] = value
829 else:
830 error('Single part property must be "suite": ' + key)
831
832 continue
833 if len(parts) != 3:
834 error('Property name does not have 3 parts separated by "@": ' + key)
835 kind, name, attr = parts
836 if kind == 'project':
837 m = suite['projects']
838 elif kind == 'library':
839 m = suite['libraries']
840 elif kind == 'jrelibrary':
841 m = suite['jrelibraries']
842 elif kind == 'distribution':
843 m = suite['distributions']
844 else:
845 error('Property name does not start with "project@", "library@" or "distribution@": ' + key)
846
847 attrs = m.get(name)
848 if attrs is None:
849 attrs = OrderedDict()
850 m[name] = attrs
851 attrs[attr] = value
852 return suite
853 790
854 def _load_suite_dict(mxDir): 791 def _load_suite_dict(mxDir):
855 792
856 suffix = 1 793 suffix = 1
857 suite = None 794 suite = None