def parse_entry_points(self): def split_and_strip(entry_point): console_script, entry_point = entry_point.split('=', 2) return console_script.strip(), entry_point.strip() raw_entry_points = self.distribution.entry_points if isinstance(raw_entry_points, string): parser = ConfigParser() parser.readfp(StringIO(raw_entry_points)) if parser.has_section('console_scripts'): return dict(parser.items('console_scripts')) elif isinstance(raw_entry_points, dict): try: return dict(split_and_strip(script) for script in raw_entry_points.get('console_scripts', [])) except ValueError: pass elif raw_entry_points is not None: die('When entry_points is provided, it must be a string or dict.') return {}
def parse_entry_points(self): def parse_entry_point_name(entry_point): script_name = entry_point.split('=', 1)[0] return script_name.strip() raw_entry_points = self.distribution.entry_points if isinstance(raw_entry_points, string): parser = ConfigParser() parser.readfp(StringIO(to_unicode(raw_entry_points))) if parser.has_section('console_scripts'): return tuple(parser.options('console_scripts')) elif isinstance(raw_entry_points, dict): try: return tuple(parse_entry_point_name(script) for script in raw_entry_points.get('console_scripts', [])) except ValueError: pass elif raw_entry_points is not None: die('When entry_points is provided, it must be a string or dict.') return ()
def parse_entry_points(self): def parse_entry_point_name(entry_point): script_name = entry_point.split('=', 1)[0] return script_name.strip() raw_entry_points = self.distribution.entry_points if isinstance(raw_entry_points, string): parser = ConfigParser() parser.readfp(StringIO(to_unicode(raw_entry_points))) if parser.has_section('console_scripts'): return tuple(parser.options('console_scripts')) elif isinstance(raw_entry_points, dict): try: return tuple( parse_entry_point_name(script) for script in raw_entry_points.get('console_scripts', [])) except ValueError: pass elif raw_entry_points is not None: die('When entry_points is provided, it must be a string or dict.') return ()