コード例 #1
0
def find_projects(args, parser):
    root = args.find
    filenames = []
    for name in xcodeprojer.find_projectfiles(root):
        filenames.append(name)
        # This might take a while, report progress
        sys.stdout.write('.')
        sys.stdout.flush()
    print()

    if not filenames:
        print('No project.pbxproj files found in "%s"' % root)
        return

    fn = rel(LISTFILENAME)
    with open(fn, 'wb') as f:
        text = '\n'.join(filenames) + '\n'
        f.write(bytestr(text))
        print('\nWrote %d filename to "%s"' % (len(filenames), fn))
コード例 #2
0
def find_projects(args, parser):
    root = args.find
    filenames = []
    for name in xcodeprojer.find_projectfiles(root):
        filenames.append(name)
        # This might take a while, report progress
        sys.stdout.write('.')
        sys.stdout.flush()
    print()

    if not filenames:
        print('No project.pbxproj files found in "%s"' % root)
        return

    fn = rel(LISTFILENAME)
    with open(fn, 'wb') as f:
        text = '\n'.join(filenames) + '\n'
        f.write(bytestr(text))
        print('\nWrote %d filename to "%s"' % (len(filenames), fn))
コード例 #3
0
def histogram(args, utcoffset=0):
    if args.emoji or args.emojitable:
        write("Please be patient when your computer is caching emoji fonts for you. This might take a minute.\n")

    build_emoji_table()
    if args.emojitable:
        print_emoji_table()
        return

    path = args.directory
    histo_year = Counter()
    histo_hour = Counter()
    users_per_year = defaultdict(set)

    pool = multiprocessing.Pool(initializer=utils.per_process_init)

    filenames = xcodeprojer.find_projectfiles(path)
    results = []

    write("Looking for Xcode ids in project files...")
    sys.stdout.flush()

    for idx, filename in enumerate(filenames):
        results.append(pool.apply_async(gidtable, [filename]))
        if args.max_files is not None and idx + 1 >= args.max_files:
            break
    pool.close()

    try:
        for asyncresult in results:
            filename, gids = asyncresult.get()
            for gid in gids:
                fields = xcodeprojer.gidfields(gids, gid)
                refdate = fields['date']
                dt = xcodeprojer.datetime_from_utc(refdate)
                histo_hour[dt.hour] += 1
                year = dt.year
                if args.startyear <= year <= args.endyear:
                    histo_year[year] += 1
                    users_per_year[year].add(fields['user'])
    except (KeyboardInterrupt, GeneratorExit):
        pool.terminate()
    finally:
        pool.join()

    writeline()
    write("At which hours are new Xcode ids created (UTC time offset: %d)" % args.utcoffset)
    print_histo(histo_hour, utcoffset=utcoffset)

    write("In which years were the Xcode ids created (we only look at %s-%s)" % (args.startyear, args.endyear))
    print_histo(histo_year)

    write("Estimated number of users creating new Xcode ids by year")
    user_histo = {k: len(v) for (k, v) in users_per_year.items()}
    print_histo(user_histo)

    writeline()
    write("The following is a list of names that might be completely unrelated to the examined Xcode projects.")
    write("For something for tangible replace firstnames.txt with your own list.")
    writeline()

    max_firstnames_limited = print_names(args, users_per_year, emoji=args.emoji)

    if args.emoji:
        write("Looking for Xcode ids in project files...")
        print_emoji_histo(users_per_year)

    if max_firstnames_limited and args.max_firstnames is None:
        write("The number of first names to consider was limited to %d, this can be changed with --max-firstnames" % max_firstnames_limited)