def test_init_noParameters():
    exampleFile = "./data/example/testUser/StreamingHistory.json"
    analyzer = Analyzer()

    numberOfItemsStreamed = 29632

    assert exampleFile == analyzer.libraryFiles[0]
    assert numberOfItemsStreamed == len(analyzer.library)
Example #2
0
    def update(self, **kwargs):
        self.settings.update_params(**kwargs)
        if not any(self.settings.rates.values()) or self.settings.update:
            print("[INFO]: Trying to get exchange rates from remote server...")
            self.exchanger.update_exchange_rates(self.settings.rates)
            self.exchanger.save_rates(self.settings.rates)

        print(f"[INFO]: Get exchange rates: {self.settings.rates}")
        self.collector = DataCollector(self.settings.rates)
        self.analyzer = Analyzer(self.settings.save_result)
Example #3
0
def test_init() -> None:
    analyzer = Analyzer("test")
    infos = analyzer.get()
    assert infos.get("name") == "test"
    assert infos.get("magic_number") is None
    assert infos.get("format") is None
    assert infos.get("bits") is None
    assert infos.get("endianness") is None
    assert infos.get("size") is None
    assert infos.get("content") is None
def test_init_multipleFilesSpecified():
    test_file = "./data/example/testUser1/StreamingHistory.json"
    test_file2 = "./data/example/testUser2/StreamingHistory.json"
    streamingHistoryFiles = [test_file, test_file2]
    analyzer = Analyzer(streamingHistoryFiles=streamingHistoryFiles)

    numberOfItemsStreamed = 8

    assert test_file == analyzer.libraryFiles[0]
    assert test_file2 == analyzer.libraryFiles[1]
    assert numberOfItemsStreamed == len(analyzer.library)
Example #5
0
def run():
    arg_parser = argparse.ArgumentParser()
    arg_parser.add_argument(
        'repo',
        type=str,
        help='GitHub public repo',
    )
    arg_parser.add_argument(
        '-df',
        '--date_from',
        type=valid_date,
        help='Analyze from date - YYYY-MM-DD',
    )
    arg_parser.add_argument(
        '-dt',
        '--date_to',
        type=valid_date,
        help='Analyze to date - YYYY-MM-DD',
    )
    arg_parser.add_argument(
        '-b',
        '--branch',
        type=str,
        default='master',
        help='Branch name to analyze. Defaults to master',
    )

    args = arg_parser.parse_args()

    repo = args.repo
    date_from = args.date_from
    date_to = args.date_to
    branch = args.branch

    analyzer = Analyzer(
        repo=repo,
        date_from=date_from,
        date_to=date_to,
        branch=branch,
    )

    result = {}
    try:
        result = analyzer.get_stats()
    except RequestException as e:
        log.error(f'Error getting stats: {e}')

    log.info(json.dumps(result, indent=2))
Example #6
0
            print ("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
            print ("     Opening data file : {0}".format(in_file_directory + in_file_name))
            print ("   - Started: " + str(start))
            print ("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n")
            log_text += "\n\n     -DATA FILE : {0} at {1}".format(in_file_directory + in_file_name, str(start))+'\n'

            ########################
            # Generate the network #
            ########################

            print ("Step 0. INITIALIZATION\n")

            # initialization - generating an Analyzer with all info to generate file handlers
            _Analyzer = Analyzer(in_file_directory, in_file_name,
                                  out_file_directory,
                                  is_weighted, is_directed, full_analysis, weight_id, aggregate_number
                                )

            _Analyzer.generate_network()

            ########################
            # Launch the analysis  #
            ########################

            print ("Step 1. ANALYSIS\n")


            _Analyzer.launch_analysis()


            ########################
Example #7
0
 def setUp(self) -> None:
     """Set up variables for testing."""
     self._analyzer = Analyzer("test", "test")
Example #8
0
        # for log
        log_text += "\n\n     - DATA FILE : {0} at {1}".format(
            in_file_directory + in_file_name, str(start)) + '\n'

        ########################
        # Read The Config File #
        ########################

        print("Step 0. CONFIG VERIFICATION\n")

        # initialization - generating an Analyzer with all info to generate file handlers
        _Analyzer = Analyzer(in_file_directory, in_file_name, in_extension,
                             in_delimiter, in_file_missing_value,
                             in_file_quote, out_file_directory, out_file_name,
                             out_extension, out_delimiter,
                             out_file_missing_value, out_file_single_file,
                             out_file_separate_line, raw_data_structure,
                             clean_data_structure)

        # verification of admitted formats (in, out and data)
        if not _Analyzer.check_valid():
            stop_system(_Analyzer.error_message)

        ##########################
        # Structure the raw data #
        ##########################

        print("Step 1. STRUCTURING THE RAW DATA\n")

        _Analyzer.structure_raw_data()
Example #9
0
 def setUp(self) -> None:
     """Set up variables for testing."""
     self._analyzer = Analyzer("test", "<title> Una ruta 6a+</title>")
Example #10
0
def analyzer():
    return Analyzer('test')
def analyzer_TestUser():
    test_file = "./data/example/testUser/StreamingHistory.json"
    return Analyzer([test_file])
Example #12
0
 def setUp(self) -> None:
     """Set up variables for testing."""
     self._analyzer = Analyzer("test", '<a src="Test" /a>')
Example #13
0
from datetime import datetime

from src.analyzer import Analyzer

last_refresh = datetime.now()

if __name__ == '__main__':
    analyzer = Analyzer()
    while True:
        country = input('Country: ')
        state = input('State: ')
        if (datetime.now() - last_refresh).seconds > 60:
            analyzer.provider.refresh()
        try:
            analyzer.plot(country, state)
        except AssertionError:
            print('Not found.')
        except TypeError:
            print('Can\'t plot record.')
Example #14
0
    elif "generatortest.py" in argv[1]:
        FILE_PATH = argv[2]
    else:
        error_msg = ("Unexpected call from the command line: {}")
        raise SyntaxError(error_msg.format(" ".join(argv)))
else:
    error_msg = ("Please pass an arg for the path to a flair program.")
    raise SyntaxError(error_msg)

# store program into string variable
with open(FILE_PATH, "r") as flr:
    flairProgram = flr.read()

scanner = Scanner(flairProgram)
parser = Parser(scanner)
ast = parser.parse()
analyzer = Analyzer(ast)
symbolTable = analyzer.getSymbolTable()
generator = Generator(ast, symbolTable)
code = generator.generateCode()
if "/" in FILE_PATH:
    fileName = FILE_PATH[FILE_PATH.rindex("/") + 1:]
else:
    fileName = FILE_PATH
if "." in fileName:
    fileName = fileName[:fileName.rindex(".")]
fileName += ".tm"
with open(fileName, 'w+') as f:
    f.write(code)
print("TM code saved to file {}".format(fileName))
Example #15
0
def main() -> None:
    analyzer = Analyzer(["./data/example/testUser/StreamingHistory.json"])
    payload: Mapping[str, Union[str, int]] = {}

    print("Example 1: getPopularArtists()")
    pa = analyzer.getPopularArtists()
    print(pa)

    print()
    print("Example 1a: getPopularArtists() with specific Daytime")
    payload = {"daytime": "morning"}
    pa = analyzer.getPopularArtists(payload=payload)
    print(pa)

    print()
    print("Example 1b: getPopularArtists() of Month July")
    payload = {"month": 7}
    pa = analyzer.getPopularArtists(payload=payload)
    print(pa)

    print()
    print("Example 1c: getPopularArtists() of Month July for podcasts")
    payload = {"month": 7, "media": "podcast"}
    pa = analyzer.getPopularArtists(payload=payload)
    print(pa)

    print()
    print(
        "Example 1d: getPopularArtists() of specified period (2019-03-03 to 2019-03-04) for music, count = 3"
    )
    payload = {
        "startYear": 2019,
        "startMonth": 3,
        "startDay": 3,
        "startHour": 0,
        "endYear": 2019,
        "endMonth": 3,
        "endDay": 4,
        "endHour": 0,
        "count": 3,
        "media": "music",
    }
    pa = analyzer.getPopularArtists(payload=payload)
    print(pa)

    print()
    print("Example 1e: getPopularArtists() for specific weekday (monday)")
    payload = {
        "weekday": "monday",
    }
    pa = analyzer.getPopularArtists(payload=payload)
    print(pa)

    print()
    print("Example 2: getPopularItems()")
    pi = analyzer.getPopularItems()
    print(pi)

    print()
    print("Example 2a: getPopularItems() for podcasts")
    payload = {
        "media": "podcast",
    }
    pi = analyzer.getPopularItems(payload=payload)
    print(pi)

    print()
    print("Example 2b: getPopularItems() for podcasts by time played in ms")
    payload = {
        "media": "podcast",
        "ratingCrit": "time",
    }
    pi = analyzer.getPopularItems(payload=payload)
    print(pi)

    print()
    print("Example 2c: getPopularItems() with keyword 'franz ferdinand'")
    pi = analyzer.getPopularItems(payload={"keyword": "Franz Ferdinand"})
    print(pi)

    print()
    print("Example 2c2: getPopularItems() with keyword 'acoustic'")
    pi = analyzer.getPopularItems(payload={"keyword": "acoustic"})
    print(pi)

    print()
    print("Example 3: getDataPerWeekday()")
    dpw = analyzer.getDataPerWeekday()
    print(dpw)

    print()
    print("Example 3a: getDataPerWeekday() with string as key")
    dpw = analyzer.getDataPerWeekday(weekdayFormat="")
    print(dpw)
Example #16
0
def analyzer_patched(mock_get):
    a = Analyzer('test')
    a._get = mock_get
    return a
Example #17
0
from sys import argv, path
import os
path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from src.parser import Parser
from src.scanner import Scanner
from src.analyzer import Analyzer

# pass in arg for path to flair program
if len(argv) > 1:
    if "analyzertest.py" in argv[0]:
        FILE_PATH = argv[1]
    elif "analyzertest.py" in argv[1]:
        FILE_PATH = argv[2]
    else:
        error_msg = ("Unexpected call from the command line: {}")
        raise SyntaxError(error_msg.format(" ".join(argv)))
else:
    error_msg = ("Please pass an arg for the path to a flair program.")
    raise SyntaxError(error_msg)

# store program into string variable
with open(FILE_PATH, "r") as flr:
    flairProgram = flr.read()

scanner = Scanner(flairProgram)
parser = Parser(scanner)
analyzer = Analyzer(parser.parse())
symbolTable = analyzer.getSymbolTable()
print("Symbol Table:\n" + str(symbolTable))
Example #18
0
def main():
    analyzer = Analyzer()
    analyzer.draw_rtt_graph(DatType.Normal)
    analyzer.write_info_csv()
    print("Complete!")
Example #19
0
def main():
    #xmldb = XMLDatabase("https://bugzilla.gnome.org/xmlrpc.cgi", "gnome")
    mongodb = MongoDatabase("https://bugzilla.gnome.org/xmlrpc.cgi", "gnome")
    bugdb = BugzillaDB(mongodb)
    man = MongoAnalyzer()
    an = Analyzer(bugdb, man)