def determine_paths(self, package_name=None, create_package_dir=False, dry_run=False):
<EOL>self.project_dir = Path(os.getenv('<STR_LIT>') or os.getcwd())<EOL>distribution = self.get_distribution()<EOL>if distribution:<EOL><INDENT>self.project_name = distribution.get_name()<EOL><DEDENT>else:<EOL><INDENT>self.project_name = self.project_dir.name<EOL><DEDENT>if os.path.isdir(self.project_dir / "<STR_LIT:src>"):<EOL><INDENT>package_search_dir = self.project_dir / "<STR_LIT:src>"<EOL><DEDENT>else:<EOL><INDENT>package_search_dir = self.project_dir<EOL><DEDENT>created_package_dir = False<EOL>if not package_name:<EOL><INDENT>package_name = self.project_name.replace("<STR_LIT:->", "<STR_LIT:_>")<EOL>def get_matches(name):<EOL><INDENT>possibles = [n for n in os.listdir(package_search_dir) if os.path.isdir(package_search_dir / n)]<EOL>return difflib.get_close_matches(name, possibles, n=<NUM_LIT:1>, cutoff=<NUM_LIT>)<EOL><DEDENT>close = get_matches(package_name)<EOL>if not close and "<STR_LIT:_>" in package_name:<EOL><INDENT>short_package_name = "<STR_LIT:_>".join(package_name.split("<STR_LIT:_>")[<NUM_LIT:1>:])<EOL>close = get_matches(short_package_name)<EOL><DEDENT>if not close:<EOL><INDENT>if create_package_dir:<EOL><INDENT>package_dir = package_search_dir / package_name<EOL>created_package_dir = True<EOL>if not dry_run:<EOL><INDENT>print("<STR_LIT>" % package_dir)<EOL>os.mkdir(package_dir)<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>" % package_dir)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CommandError("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>package_name = close[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>self.package_name = package_name<EOL>self.package_dir = package_search_dir / package_name<EOL>if not os.path.exists(self.package_dir) and not created_package_dir:<EOL><INDENT>raise CommandError("<STR_LIT>" % self.package_dir)<EOL><DEDENT>
Determine paths automatically and a little intelligently