diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-03-24 09:21:53 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-03-25 17:25:54 +0000 |
commit | c6940a97958be1d9981a3b5fb3ae27f74414e57f (patch) | |
tree | 63a1718995922da10404dd0429e092140e67464e /bitbake/lib/bb/utils.py | |
parent | ec3f9089485a4d77f777c3512646874f608bcc2d (diff) | |
download | poky-c6940a97958be1d9981a3b5fb3ae27f74414e57f.tar.gz |
bb.utils: remove old portage remnants
The following utility functions were removed. Note that in this particular
case we're bypassing a proper deprecation process, as these functions are
clearly not utilized, are obvious remnants of old ways of doing things, and
some of which do not even function properly.
- tokenize
- evaluate
- flatten
- relparse
- ververify
- isjustname
- isspecific
- catpkgsplit
- pkgsplit
- pkgcmp
- dep_parenreduce
- dep_opconvert
(Bitbake rev: 62983ad9b151ee8d51e8cf9a31c736c7813edf16)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 571 |
1 files changed, 0 insertions, 571 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index ef049f7c7b..5b7e7a3608 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -615,574 +615,3 @@ def which(path, item, direction = 0): | |||
615 | return next | 615 | return next |
616 | 616 | ||
617 | return "" | 617 | return "" |
618 | |||
619 | whitespace = '\t\n\x0b\x0c\r ' | ||
620 | lowercase = 'abcdefghijklmnopqrstuvwxyz' | ||
621 | |||
622 | def tokenize(mystring): | ||
623 | """Breaks a string like 'foo? (bar) oni? (blah (blah))' into (possibly embedded) lists: | ||
624 | |||
625 | >>> tokenize("x") | ||
626 | ['x'] | ||
627 | >>> tokenize("x y") | ||
628 | ['x', 'y'] | ||
629 | >>> tokenize("(x y)") | ||
630 | [['x', 'y']] | ||
631 | >>> tokenize("(x y) b c") | ||
632 | [['x', 'y'], 'b', 'c'] | ||
633 | >>> tokenize("foo? (bar) oni? (blah (blah))") | ||
634 | ['foo?', ['bar'], 'oni?', ['blah', ['blah']]] | ||
635 | >>> tokenize("sys-apps/linux-headers nls? (sys-devel/gettext)") | ||
636 | ['sys-apps/linux-headers', 'nls?', ['sys-devel/gettext']] | ||
637 | """ | ||
638 | |||
639 | newtokens = [] | ||
640 | curlist = newtokens | ||
641 | prevlists = [] | ||
642 | level = 0 | ||
643 | accum = "" | ||
644 | for x in mystring: | ||
645 | if x=="(": | ||
646 | if accum: | ||
647 | curlist.append(accum) | ||
648 | accum="" | ||
649 | prevlists.append(curlist) | ||
650 | curlist=[] | ||
651 | level=level+1 | ||
652 | elif x==")": | ||
653 | if accum: | ||
654 | curlist.append(accum) | ||
655 | accum="" | ||
656 | if level==0: | ||
657 | print "!!! tokenizer: Unmatched left parenthesis in:\n'"+mystring+"'" | ||
658 | return None | ||
659 | newlist=curlist | ||
660 | curlist=prevlists.pop() | ||
661 | curlist.append(newlist) | ||
662 | level=level-1 | ||
663 | elif x in whitespace: | ||
664 | if accum: | ||
665 | curlist.append(accum) | ||
666 | accum="" | ||
667 | else: | ||
668 | accum=accum+x | ||
669 | if accum: | ||
670 | curlist.append(accum) | ||
671 | if (level!=0): | ||
672 | print "!!! tokenizer: Exiting with unterminated parenthesis in:\n'"+mystring+"'" | ||
673 | return None | ||
674 | return newtokens | ||
675 | |||
676 | def evaluate(tokens,mydefines,allon=0): | ||
677 | """Removes tokens based on whether conditional definitions exist or not. | ||
678 | Recognizes ! | ||
679 | |||
680 | >>> evaluate(['sys-apps/linux-headers', 'nls?', ['sys-devel/gettext']], {}) | ||
681 | ['sys-apps/linux-headers'] | ||
682 | |||
683 | Negate the flag: | ||
684 | |||
685 | >>> evaluate(['sys-apps/linux-headers', '!nls?', ['sys-devel/gettext']], {}) | ||
686 | ['sys-apps/linux-headers', ['sys-devel/gettext']] | ||
687 | |||
688 | Define 'nls': | ||
689 | |||
690 | >>> evaluate(['sys-apps/linux-headers', 'nls?', ['sys-devel/gettext']], {"nls":1}) | ||
691 | ['sys-apps/linux-headers', ['sys-devel/gettext']] | ||
692 | |||
693 | Turn allon on: | ||
694 | |||
695 | >>> evaluate(['sys-apps/linux-headers', 'nls?', ['sys-devel/gettext']], {}, True) | ||
696 | ['sys-apps/linux-headers', ['sys-devel/gettext']] | ||
697 | """ | ||
698 | |||
699 | if tokens == None: | ||
700 | return None | ||
701 | mytokens = tokens + [] # this copies the list | ||
702 | pos = 0 | ||
703 | while pos < len(mytokens): | ||
704 | if type(mytokens[pos]) == types.ListType: | ||
705 | evaluate(mytokens[pos], mydefines) | ||
706 | if not len(mytokens[pos]): | ||
707 | del mytokens[pos] | ||
708 | continue | ||
709 | elif mytokens[pos][-1] == "?": | ||
710 | cur = mytokens[pos][:-1] | ||
711 | del mytokens[pos] | ||
712 | if allon: | ||
713 | if cur[0] == "!": | ||
714 | del mytokens[pos] | ||
715 | else: | ||
716 | if cur[0] == "!": | ||
717 | if (cur[1:] in mydefines) and (pos < len(mytokens)): | ||
718 | del mytokens[pos] | ||
719 | continue | ||
720 | elif (cur not in mydefines) and (pos < len(mytokens)): | ||
721 | del mytokens[pos] | ||
722 | continue | ||
723 | pos = pos + 1 | ||
724 | return mytokens | ||
725 | |||
726 | def flatten(mytokens): | ||
727 | """Converts nested arrays into a flat arrays: | ||
728 | |||
729 | >>> flatten([1,[2,3]]) | ||
730 | [1, 2, 3] | ||
731 | >>> flatten(['sys-apps/linux-headers', ['sys-devel/gettext']]) | ||
732 | ['sys-apps/linux-headers', 'sys-devel/gettext'] | ||
733 | """ | ||
734 | |||
735 | newlist=[] | ||
736 | for x in mytokens: | ||
737 | if type(x)==types.ListType: | ||
738 | newlist.extend(flatten(x)) | ||
739 | else: | ||
740 | newlist.append(x) | ||
741 | return newlist | ||
742 | |||
743 | _package_weights_ = {"pre":-2,"p":0,"alpha":-4,"beta":-3,"rc":-1} # dicts are unordered | ||
744 | _package_ends_ = ["pre", "p", "alpha", "beta", "rc", "cvs", "bk", "HEAD" ] # so we need ordered list | ||
745 | |||
746 | def relparse(myver): | ||
747 | """Parses the last elements of a version number into a triplet, that can | ||
748 | later be compared: | ||
749 | |||
750 | >>> relparse('1.2_pre3') | ||
751 | [1.2, -2, 3.0] | ||
752 | >>> relparse('1.2b') | ||
753 | [1.2, 98, 0] | ||
754 | >>> relparse('1.2') | ||
755 | [1.2, 0, 0] | ||
756 | """ | ||
757 | |||
758 | number = 0 | ||
759 | p1 = 0 | ||
760 | p2 = 0 | ||
761 | mynewver = myver.split('_') | ||
762 | if len(mynewver)==2: | ||
763 | # an _package_weights_ | ||
764 | number = float(mynewver[0]) | ||
765 | match = 0 | ||
766 | for x in _package_ends_: | ||
767 | elen = len(x) | ||
768 | if mynewver[1][:elen] == x: | ||
769 | match = 1 | ||
770 | p1 = _package_weights_[x] | ||
771 | try: | ||
772 | p2 = float(mynewver[1][elen:]) | ||
773 | except: | ||
774 | p2 = 0 | ||
775 | break | ||
776 | if not match: | ||
777 | # normal number or number with letter at end | ||
778 | divider = len(myver)-1 | ||
779 | if myver[divider:] not in "1234567890": | ||
780 | # letter at end | ||
781 | p1 = ord(myver[divider:]) | ||
782 | number = float(myver[0:divider]) | ||
783 | else: | ||
784 | number = float(myver) | ||
785 | else: | ||
786 | # normal number or number with letter at end | ||
787 | divider = len(myver)-1 | ||
788 | if myver[divider:] not in "1234567890": | ||
789 | #letter at end | ||
790 | p1 = ord(myver[divider:]) | ||
791 | number = float(myver[0:divider]) | ||
792 | else: | ||
793 | number = float(myver) | ||
794 | return [number,p1,p2] | ||
795 | |||
796 | __ververify_cache__ = {} | ||
797 | |||
798 | def ververify(myorigval,silent=1): | ||
799 | """Returns 1 if given a valid version string, els 0. Valid versions are in the format | ||
800 | |||
801 | <v1>.<v2>...<vx>[a-z,_{_package_weights_}[vy]] | ||
802 | |||
803 | >>> ververify('2.4.20') | ||
804 | 1 | ||
805 | >>> ververify('2.4..20') # two dots | ||
806 | 0 | ||
807 | >>> ververify('2.x.20') # 'x' is not numeric | ||
808 | 0 | ||
809 | >>> ververify('2.4.20a') | ||
810 | 1 | ||
811 | >>> ververify('2.4.20cvs') # only one trailing letter | ||
812 | 0 | ||
813 | >>> ververify('1a') | ||
814 | 1 | ||
815 | >>> ververify('test_a') # no version at all | ||
816 | 0 | ||
817 | >>> ververify('2.4.20_beta1') | ||
818 | 1 | ||
819 | >>> ververify('2.4.20_beta') | ||
820 | 1 | ||
821 | >>> ververify('2.4.20_wrongext') # _wrongext is no valid trailer | ||
822 | 0 | ||
823 | """ | ||
824 | |||
825 | # Lookup the cache first | ||
826 | try: | ||
827 | return __ververify_cache__[myorigval] | ||
828 | except KeyError: | ||
829 | pass | ||
830 | |||
831 | if len(myorigval) == 0: | ||
832 | if not silent: | ||
833 | bb.error("package version is empty") | ||
834 | __ververify_cache__[myorigval] = 0 | ||
835 | return 0 | ||
836 | myval = myorigval.split('.') | ||
837 | if len(myval)==0: | ||
838 | if not silent: | ||
839 | bb.error("package name has empty version string") | ||
840 | __ververify_cache__[myorigval] = 0 | ||
841 | return 0 | ||
842 | # all but the last version must be a numeric | ||
843 | for x in myval[:-1]: | ||
844 | if not len(x): | ||
845 | if not silent: | ||
846 | bb.error("package version has two points in a row") | ||
847 | __ververify_cache__[myorigval] = 0 | ||
848 | return 0 | ||
849 | try: | ||
850 | foo = int(x) | ||
851 | except: | ||
852 | if not silent: | ||
853 | bb.error("package version contains non-numeric '"+x+"'") | ||
854 | __ververify_cache__[myorigval] = 0 | ||
855 | return 0 | ||
856 | if not len(myval[-1]): | ||
857 | if not silent: | ||
858 | bb.error("package version has trailing dot") | ||
859 | __ververify_cache__[myorigval] = 0 | ||
860 | return 0 | ||
861 | try: | ||
862 | foo = int(myval[-1]) | ||
863 | __ververify_cache__[myorigval] = 1 | ||
864 | return 1 | ||
865 | except: | ||
866 | pass | ||
867 | |||
868 | # ok, our last component is not a plain number or blank, let's continue | ||
869 | if myval[-1][-1] in lowercase: | ||
870 | try: | ||
871 | foo = int(myval[-1][:-1]) | ||
872 | return 1 | ||
873 | __ververify_cache__[myorigval] = 1 | ||
874 | # 1a, 2.0b, etc. | ||
875 | except: | ||
876 | pass | ||
877 | # ok, maybe we have a 1_alpha or 1_beta2; let's see | ||
878 | ep=string.split(myval[-1],"_") | ||
879 | if len(ep)!= 2: | ||
880 | if not silent: | ||
881 | bb.error("package version has more than one letter at then end") | ||
882 | __ververify_cache__[myorigval] = 0 | ||
883 | return 0 | ||
884 | try: | ||
885 | foo = string.atoi(ep[0]) | ||
886 | except: | ||
887 | # this needs to be numeric, i.e. the "1" in "1_alpha" | ||
888 | if not silent: | ||
889 | bb.error("package version must have numeric part before the '_'") | ||
890 | __ververify_cache__[myorigval] = 0 | ||
891 | return 0 | ||
892 | |||
893 | for mye in _package_ends_: | ||
894 | if ep[1][0:len(mye)] == mye: | ||
895 | if len(mye) == len(ep[1]): | ||
896 | # no trailing numeric is ok | ||
897 | __ververify_cache__[myorigval] = 1 | ||
898 | return 1 | ||
899 | else: | ||
900 | try: | ||
901 | foo = string.atoi(ep[1][len(mye):]) | ||
902 | __ververify_cache__[myorigval] = 1 | ||
903 | return 1 | ||
904 | except: | ||
905 | # if no _package_weights_ work, *then* we return 0 | ||
906 | pass | ||
907 | if not silent: | ||
908 | bb.error("package version extension after '_' is invalid") | ||
909 | __ververify_cache__[myorigval] = 0 | ||
910 | return 0 | ||
911 | |||
912 | def isjustname(mypkg): | ||
913 | myparts = string.split(mypkg,'-') | ||
914 | for x in myparts: | ||
915 | if ververify(x): | ||
916 | return 0 | ||
917 | return 1 | ||
918 | |||
919 | _isspecific_cache_={} | ||
920 | |||
921 | def isspecific(mypkg): | ||
922 | "now supports packages with no category" | ||
923 | try: | ||
924 | return __isspecific_cache__[mypkg] | ||
925 | except: | ||
926 | pass | ||
927 | |||
928 | mysplit = string.split(mypkg,"/") | ||
929 | if not isjustname(mysplit[-1]): | ||
930 | __isspecific_cache__[mypkg] = 1 | ||
931 | return 1 | ||
932 | __isspecific_cache__[mypkg] = 0 | ||
933 | return 0 | ||
934 | |||
935 | __pkgsplit_cache__={} | ||
936 | |||
937 | def pkgsplit(mypkg, silent=1): | ||
938 | |||
939 | """This function can be used as a package verification function. If | ||
940 | it is a valid name, pkgsplit will return a list containing: | ||
941 | [pkgname, pkgversion(norev), pkgrev ]. | ||
942 | |||
943 | >>> pkgsplit('') | ||
944 | >>> pkgsplit('x') | ||
945 | >>> pkgsplit('x-') | ||
946 | >>> pkgsplit('-1') | ||
947 | >>> pkgsplit('glibc-1.2-8.9-r7') | ||
948 | >>> pkgsplit('glibc-2.2.5-r7') | ||
949 | ['glibc', '2.2.5', 'r7'] | ||
950 | >>> pkgsplit('foo-1.2-1') | ||
951 | >>> pkgsplit('Mesa-3.0') | ||
952 | ['Mesa', '3.0', 'r0'] | ||
953 | """ | ||
954 | |||
955 | try: | ||
956 | return __pkgsplit_cache__[mypkg] | ||
957 | except KeyError: | ||
958 | pass | ||
959 | |||
960 | myparts = string.split(mypkg,'-') | ||
961 | if len(myparts) < 2: | ||
962 | if not silent: | ||
963 | bb.error("package name without name or version part") | ||
964 | __pkgsplit_cache__[mypkg] = None | ||
965 | return None | ||
966 | for x in myparts: | ||
967 | if len(x) == 0: | ||
968 | if not silent: | ||
969 | bb.error("package name with empty name or version part") | ||
970 | __pkgsplit_cache__[mypkg] = None | ||
971 | return None | ||
972 | # verify rev | ||
973 | revok = 0 | ||
974 | myrev = myparts[-1] | ||
975 | ververify(myrev, silent) | ||
976 | if len(myrev) and myrev[0] == "r": | ||
977 | try: | ||
978 | string.atoi(myrev[1:]) | ||
979 | revok = 1 | ||
980 | except: | ||
981 | pass | ||
982 | if revok: | ||
983 | if ververify(myparts[-2]): | ||
984 | if len(myparts) == 2: | ||
985 | __pkgsplit_cache__[mypkg] = None | ||
986 | return None | ||
987 | else: | ||
988 | for x in myparts[:-2]: | ||
989 | if ververify(x): | ||
990 | __pkgsplit_cache__[mypkg]=None | ||
991 | return None | ||
992 | # names can't have versiony looking parts | ||
993 | myval=[string.join(myparts[:-2],"-"),myparts[-2],myparts[-1]] | ||
994 | __pkgsplit_cache__[mypkg]=myval | ||
995 | return myval | ||
996 | else: | ||
997 | __pkgsplit_cache__[mypkg] = None | ||
998 | return None | ||
999 | |||
1000 | elif ververify(myparts[-1],silent): | ||
1001 | if len(myparts)==1: | ||
1002 | if not silent: | ||
1003 | print "!!! Name error in",mypkg+": missing name part." | ||
1004 | __pkgsplit_cache__[mypkg]=None | ||
1005 | return None | ||
1006 | else: | ||
1007 | for x in myparts[:-1]: | ||
1008 | if ververify(x): | ||
1009 | if not silent: bb.error("package name has multiple version parts") | ||
1010 | __pkgsplit_cache__[mypkg] = None | ||
1011 | return None | ||
1012 | myval = [string.join(myparts[:-1],"-"), myparts[-1],"r0"] | ||
1013 | __pkgsplit_cache__[mypkg] = myval | ||
1014 | return myval | ||
1015 | else: | ||
1016 | __pkgsplit_cache__[mypkg] = None | ||
1017 | return None | ||
1018 | |||
1019 | __catpkgsplit_cache__ = {} | ||
1020 | |||
1021 | def catpkgsplit(mydata,silent=1): | ||
1022 | """returns [cat, pkgname, version, rev ] | ||
1023 | |||
1024 | >>> catpkgsplit('sys-libs/glibc-1.2-r7') | ||
1025 | ['sys-libs', 'glibc', '1.2', 'r7'] | ||
1026 | >>> catpkgsplit('glibc-1.2-r7') | ||
1027 | [None, 'glibc', '1.2', 'r7'] | ||
1028 | """ | ||
1029 | |||
1030 | try: | ||
1031 | return __catpkgsplit_cache__[mydata] | ||
1032 | except KeyError: | ||
1033 | pass | ||
1034 | |||
1035 | cat = os.path.basename(os.path.dirname(mydata)) | ||
1036 | mydata = os.path.join(cat, os.path.basename(mydata)) | ||
1037 | if mydata[-3:] == '.bb': | ||
1038 | mydata = mydata[:-3] | ||
1039 | |||
1040 | mysplit = mydata.split("/") | ||
1041 | p_split = None | ||
1042 | splitlen = len(mysplit) | ||
1043 | if splitlen == 1: | ||
1044 | retval = [None] | ||
1045 | p_split = pkgsplit(mydata,silent) | ||
1046 | else: | ||
1047 | retval = [mysplit[splitlen - 2]] | ||
1048 | p_split = pkgsplit(mysplit[splitlen - 1],silent) | ||
1049 | if not p_split: | ||
1050 | __catpkgsplit_cache__[mydata] = None | ||
1051 | return None | ||
1052 | retval.extend(p_split) | ||
1053 | __catpkgsplit_cache__[mydata] = retval | ||
1054 | return retval | ||
1055 | |||
1056 | def pkgcmp(pkg1,pkg2): | ||
1057 | """ Compares two packages, which should have been split via | ||
1058 | pkgsplit(). if the return value val is less than zero, then pkg2 is | ||
1059 | newer than pkg1, zero if equal and positive if older. | ||
1060 | |||
1061 | >>> pkgcmp(['glibc', '2.2.5', 'r7'], ['glibc', '2.2.5', 'r7']) | ||
1062 | 0 | ||
1063 | >>> pkgcmp(['glibc', '2.2.5', 'r4'], ['glibc', '2.2.5', 'r7']) | ||
1064 | -1 | ||
1065 | >>> pkgcmp(['glibc', '2.2.5', 'r7'], ['glibc', '2.2.5', 'r2']) | ||
1066 | 1 | ||
1067 | """ | ||
1068 | |||
1069 | mycmp = vercmp(pkg1[1],pkg2[1]) | ||
1070 | if mycmp > 0: | ||
1071 | return 1 | ||
1072 | if mycmp < 0: | ||
1073 | return -1 | ||
1074 | r1=string.atoi(pkg1[2][1:]) | ||
1075 | r2=string.atoi(pkg2[2][1:]) | ||
1076 | if r1 > r2: | ||
1077 | return 1 | ||
1078 | if r2 > r1: | ||
1079 | return -1 | ||
1080 | return 0 | ||
1081 | |||
1082 | def dep_parenreduce(mysplit, mypos=0): | ||
1083 | """Accepts a list of strings, and converts '(' and ')' surrounded items to sub-lists: | ||
1084 | |||
1085 | >>> dep_parenreduce(['']) | ||
1086 | [''] | ||
1087 | >>> dep_parenreduce(['1', '2', '3']) | ||
1088 | ['1', '2', '3'] | ||
1089 | >>> dep_parenreduce(['1', '(', '2', '3', ')', '4']) | ||
1090 | ['1', ['2', '3'], '4'] | ||
1091 | """ | ||
1092 | |||
1093 | while mypos < len(mysplit): | ||
1094 | if mysplit[mypos] == "(": | ||
1095 | firstpos = mypos | ||
1096 | mypos = mypos + 1 | ||
1097 | while mypos < len(mysplit): | ||
1098 | if mysplit[mypos] == ")": | ||
1099 | mysplit[firstpos:mypos+1] = [mysplit[firstpos+1:mypos]] | ||
1100 | mypos = firstpos | ||
1101 | break | ||
1102 | elif mysplit[mypos] == "(": | ||
1103 | # recurse | ||
1104 | mysplit = dep_parenreduce(mysplit,mypos) | ||
1105 | mypos = mypos + 1 | ||
1106 | mypos = mypos + 1 | ||
1107 | return mysplit | ||
1108 | |||
1109 | def dep_opconvert(mysplit, myuse): | ||
1110 | "Does dependency operator conversion" | ||
1111 | |||
1112 | mypos = 0 | ||
1113 | newsplit = [] | ||
1114 | while mypos < len(mysplit): | ||
1115 | if type(mysplit[mypos]) == types.ListType: | ||
1116 | newsplit.append(dep_opconvert(mysplit[mypos],myuse)) | ||
1117 | mypos += 1 | ||
1118 | elif mysplit[mypos] == ")": | ||
1119 | # mismatched paren, error | ||
1120 | return None | ||
1121 | elif mysplit[mypos]=="||": | ||
1122 | if ((mypos+1)>=len(mysplit)) or (type(mysplit[mypos+1])!=types.ListType): | ||
1123 | # || must be followed by paren'd list | ||
1124 | return None | ||
1125 | try: | ||
1126 | mynew = dep_opconvert(mysplit[mypos+1],myuse) | ||
1127 | except Exception, e: | ||
1128 | bb.error("unable to satisfy OR dependancy: " + string.join(mysplit," || ")) | ||
1129 | raise e | ||
1130 | mynew[0:0] = ["||"] | ||
1131 | newsplit.append(mynew) | ||
1132 | mypos += 2 | ||
1133 | elif mysplit[mypos][-1] == "?": | ||
1134 | # use clause, i.e "gnome? ( foo bar )" | ||
1135 | # this is a quick and dirty hack so that repoman can enable all USE vars: | ||
1136 | if (len(myuse) == 1) and (myuse[0] == "*"): | ||
1137 | # enable it even if it's ! (for repoman) but kill it if it's | ||
1138 | # an arch variable that isn't for this arch. XXX Sparc64? | ||
1139 | if (mysplit[mypos][:-1] not in settings.usemask) or \ | ||
1140 | (mysplit[mypos][:-1]==settings["ARCH"]): | ||
1141 | enabled=1 | ||
1142 | else: | ||
1143 | enabled=0 | ||
1144 | else: | ||
1145 | if mysplit[mypos][0] == "!": | ||
1146 | myusevar = mysplit[mypos][1:-1] | ||
1147 | enabled = not myusevar in myuse | ||
1148 | #if myusevar in myuse: | ||
1149 | # enabled = 0 | ||
1150 | #else: | ||
1151 | # enabled = 1 | ||
1152 | else: | ||
1153 | myusevar=mysplit[mypos][:-1] | ||
1154 | enabled = myusevar in myuse | ||
1155 | #if myusevar in myuse: | ||
1156 | # enabled=1 | ||
1157 | #else: | ||
1158 | # enabled=0 | ||
1159 | if (mypos +2 < len(mysplit)) and (mysplit[mypos+2] == ":"): | ||
1160 | # colon mode | ||
1161 | if enabled: | ||
1162 | # choose the first option | ||
1163 | if type(mysplit[mypos+1]) == types.ListType: | ||
1164 | newsplit.append(dep_opconvert(mysplit[mypos+1],myuse)) | ||
1165 | else: | ||
1166 | newsplit.append(mysplit[mypos+1]) | ||
1167 | else: | ||
1168 | # choose the alternate option | ||
1169 | if type(mysplit[mypos+1]) == types.ListType: | ||
1170 | newsplit.append(dep_opconvert(mysplit[mypos+3],myuse)) | ||
1171 | else: | ||
1172 | newsplit.append(mysplit[mypos+3]) | ||
1173 | mypos += 4 | ||
1174 | else: | ||
1175 | # normal use mode | ||
1176 | if enabled: | ||
1177 | if type(mysplit[mypos+1]) == types.ListType: | ||
1178 | newsplit.append(dep_opconvert(mysplit[mypos+1],myuse)) | ||
1179 | else: | ||
1180 | newsplit.append(mysplit[mypos+1]) | ||
1181 | # otherwise, continue | ||
1182 | mypos += 2 | ||
1183 | else: | ||
1184 | # normal item | ||
1185 | newsplit.append(mysplit[mypos]) | ||
1186 | mypos += 1 | ||
1187 | return newsplit | ||
1188 | |||