<commit_before>#! /usr/bin/env python
# -*- coding: utf-8 -*-

"""
Usage:
  bookmarks2maxfield.py <input_file> [<output_file>]

Description:
  Input generator for Ingress Maxfield
  (http://www.ingress-maxfield.com), which uses the export of the
  IITC Bookmarks Plugin as input.

  1. Mark your portal set in IITC as bookmarks (Bookmarks Plugin).
  2. Export it as file.
  3. Run this script with the exported file as <input_file> and use the 
     result (standard output or content of <output_file>) as input for 
     Ingress Maxfield (http://www.ingress-maxfield.com)

  input_file:
    IITC Bookmark Plugin export in JSON format, e.g. 'bookmarks.json'
    
  output_file:
    generated output in CSV format, e.g. 'maxfield.csv'
"""  

import sys
import codecs
import json
from docopt import docopt

args = docopt(__doc__)

input_file = args['<input_file>']
output_file = ''
if args['<output_file>'] != None:
    output_file = args['<output_file>']
    f_output = codecs.open(output_file, 'wb')

with codecs.open(input_file,'r', encoding='utf-8') as f_input:

    d = json.load(f_input)
    
    for id in d['portals']['idOthers']['bkmrk']:
        gpscoords=d['portals']['idOthers']['bkmrk'][id]["latlng"]
        portalname=d['portals']['idOthers']['bkmrk'][id]["label"].replace(",","")
        str = '%s,https://www.ingress.com/intel?ll=%s&z=18&pll=%s,0\n' % (portalname, gpscoords, gpscoords)
        if output_file != '':
            str = str.encode('utf-8')
            f_output.write(str)
        else:
            if sys.version_info < (3, 0):
                str = str.encode('utf-8')
            sys.stdout.write(str)

f_input.close()
if output_file != '':
    f_output.close()
<commit_msg>change syntax to new version of maxfiels<commit_after>#! /usr/bin/env python
# -*- coding: utf-8 -*-

"""
Usage:
  bookmarks2maxfield.py <input_file> [<output_file>]

Description:
  Input generator for Ingress Maxfield
  (http://www.ingress-maxfield.com), which uses the export of the
  IITC Bookmarks Plugin as input.

  1. Mark your portal set in IITC as bookmarks (Bookmarks Plugin).
  2. Export it as file.
  3. Run this script with the exported file as <input_file> and use the 
     result (standard output or content of <output_file>) as input for 
     Ingress Maxfield (http://www.ingress-maxfield.com)

  input_file:
    IITC Bookmark Plugin export in JSON format, e.g. 'bookmarks.json'
    
  output_file:
    generated output in CSV format, e.g. 'maxfield.csv'
"""  

import sys
import codecs
import json
from docopt import docopt

args = docopt(__doc__)

input_file = args['<input_file>']
output_file = ''
if args['<output_file>'] != None:
    output_file = args['<output_file>']
    f_output = codecs.open(output_file, 'wb')

with codecs.open(input_file,'r', encoding='utf-8') as f_input:

    d = json.load(f_input)
    
    for id in d['portals']['idOthers']['bkmrk']:
        gpscoords=d['portals']['idOthers']['bkmrk'][id]["latlng"]
        portalname=d['portals']['idOthers']['bkmrk'][id]["label"].replace(",","")
        str = '%s;https://www.ingress.com/intel?ll=%s&z=18&pll=%s;0\n' % (portalname, gpscoords, gpscoords)
        if output_file != '':
            str = str.encode('utf-8')
            f_output.write(str)
        else:
            if sys.version_info < (3, 0):
                str = str.encode('utf-8')
            sys.stdout.write(str)

f_input.close()
if output_file != '':
    f_output.close()

{'fraction_non_alphanumeric': 0.15062518173887757, 'fraction_numerical': 0.00756033730735679, 'mean_word_length': 3.231242312423124, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7619972', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1182, 'n_words': 296}