"modules" : set(),
"avoid" : set(),
"files" : set(),
+ "copymode" : None,
+ "local_copymode" : None,
}
_OPTIONS_ = frozenset({
"tests",
Longrunning = (1 << 3)
Privileged = (1 << 4)
Unportable = (1 << 5)
+ Copyrights = (1 << 6)
AllTests = (Obsolete | Tests | CXX | Longrunning | Privileged | Unportable)
return "GL_{0}".format(prefix) if prefix == default else "GL"
+ @property
+ def copymode(self):
+ return self.__table["copymode"]
+
+ @copymode.setter
+ def copymode(self, value):
+ if value not in frozenset({None, "symlink", "hardlink"}):
+ raise ValueError("copymode: None, 'symlink' or 'hardlink'")
+ self.__table["copymode"] = value
+
+
+ @property
+ def local_copymode(self):
+ return self.__table["local_copymode"]
+
+ @local_copymode.setter
+ def local_copymode(self, value):
+ if value not in frozenset({None, "symlink", "hardlink"}):
+ raise ValueError("local_copymode: None, 'symlink' or 'hardlink'")
+ self.__table["local_copymode"] = value
+
+
+ @property
+ def copyrights(self):
+ return bool(self.__table["options"] & Base._Option_.Copyrights)
+
+ @copyrights.setter
+ def copyrights(self, value):
+ _type_assert_("copyrights", value, bool)
+ if value:
+ self.__table["options"] |= Base._Option_.Copyrights
+ else:
+ self.__table["options"] &= ~Base._Option_.Copyrights
+
+
def __getitem__(self, key):
table = (set(Base._TABLE_.keys()) | Base._OPTIONS_)
if key not in table:
super().__call__(parser, namespace, value, option)
- class _LinkOption_(_Option_):
+ class _CopyModeOption_(_Option_):
def __init__(self, *args, **kwargs):
super().__init__(nargs=0, *args, **kwargs)
def __call__(self, parser, namespace, value, option=None):
if not hasattr(namespace, self.dest):
- setattr(namespace, self.dest, CommandLine._LINK_NOTICE_)
- value = getattr(namespace, self.dest)
- symlink = ("-s", "--symlink", "--local-symlink", "-S", "--more-symlink")
- hardlink = ("-h", "--hardlink", "--local-hardlink", "-H", "--more-hardlink")
- local = ("--local-symlink", "--local-hardlink")
- disable_notice = ("-S", "--more-symlink", "-H", "--more-hardlink")
- if option in symlink:
- if value & CommandLine._LINK_HARD_:
- parser.error("conflicting --symlink and --hardlink options")
- value |= CommandLine._LINK_SYMBOLIC_
- if option in hardlink:
- if value & CommandLine._LINK_SYMBOLIC_:
- parser.error("conflicting --symlink and --hardlink options")
- value |= CommandLine._LINK_HARD_
- if option in local:
- value |= CommandLine._LINK_LOCAL_
- if option in disable_notice:
- value &= ~CommandLine._LINK_NOTICE_
+ setattr(namespace, self.dest, None)
+ if option.endswith("symlink"):
+ value = "symlink"
+ elif option.endswith("hardlink"):
+ value = "hardlink"
+ else:
+ fmt = "{}: None, 'symlink' or 'hardlink'"
+ raise ValueError(fmt.format(self.dest))
+ super().__call__(parser, namespace, value, option)
+
+
+ class _CopyrightsCopyModeOption_(_CopyModeOption_):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
+ def __call__(self, parser, namespace, value, option=None):
+ if not hasattr(namespace, self.dest):
+ setattr(namespace, "copyrights", False)
+ if option.endswith("symlink"):
+ value = "symlink"
+ elif option.endswith("hardlink"):
+ value = "hardlink"
+ else:
+ fmt = "{}: None, 'symlink' or 'hardlink'"
+ raise ValueError(fmt.format(self.dest))
+ setattr(namespace, "copyrights", True)
super().__call__(parser, namespace, value, option)
"help": (
"make symbolic links instead of copying files",
),
- "action": _LinkOption_,
- "dest": "link",
+ "action": _CopyModeOption_,
+ "dest": "copymode",
}),
(["--local-symlink"], {
"help": (
"make symbolic links instead of copying files, only",
"for files from the local override directory"
),
- "action": _LinkOption_,
- "dest": "link",
+ "action": _CopyModeOption_,
+ "dest": "local_copymode",
}),
(["-h", "--hardlink"], {
"help": (
"make hard links instead of copying files",
),
- "action": _LinkOption_,
- "dest": "link",
+ "action": _CopyModeOption_,
+ "dest": "copymode",
}),
(["--local-hardlink"], {
"help": (
"make hard links instead of copying files, only",
"for files from the local override directory"
),
- "action": _LinkOption_,
- "dest": "link",
+ "action": _CopyModeOption_,
+ "dest": "local_copymode",
}),
),
),
"make symbolic links instead of copying files and",
"don't replace copyright notices",
),
- "action": _LinkOption_,
- "dest": "link",
+ "action": _CopyrightsCopyModeOption_,
+ "dest": "copymode",
}),
(["-H", "--more-hardlink"], {
"help": (
"make symbolic links instead of copying files and",
"don't replace copyright notices",
),
- "action": _LinkOption_,
- "dest": "link",
+ "action": _CopyrightsCopyModeOption_,
+ "dest": "copymode",
}),
),
),
class Option:
"""option bitwise flags"""
DryRun = (1 << 0)
- Symlink = (1 << 1)
- Hardlink = (1 << 2)
- OnlyLocalLinks = (1 << 3)
- UpdateCopyrights = (1 << 4)
- SingleConfigure = (1 << 5)
+ SingleConfigure = (1 << 1)
def __init__(self, program):
verbosity = namespace.pop("verbosity", 0)
if namespace.pop("dry_run", False):
options |= CommandLine.Option.DryRun
- link = namespace.pop("link", None)
- if link is not None:
- if link & CommandLine._LINK_SYMBOLIC_:
- options |= CommandLine.Option.Symlink
- if link & CommandLine._LINK_HARD_:
- options |= CommandLine.Option.Hardlink
- if link & CommandLine._LINK_LOCAL_:
- options |= CommandLine.Option.OnlyLocalLinks
- if link & CommandLine._LINK_NOTICE_:
- options |= CommandLine.Option.UpdateCopyrights
if namespace.pop("single_configure", False):
options |= CommandLine.Option.SingleConfigure
namespace.pop("no_changelog", None)