<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# lccs.py - <NAME> (<EMAIL>) - Aug 2018
# License: MIT - see LICENSE for the full text.

'''This contains functions to search for objects and get light curves from a
Light Curve Collection server (https://github.com/waqasbhatti/lcc-server) using
its HTTP API.

The LCC-Server requires an API key to access most services. The service
functions in this module will automatically acquire an anonymous user API key on
first use (and upon API key expiry afterwards). If you sign up for an LCC-Server
user account, you can import the API key generated for that account on the user
home page. To do this, use the import_apikey function in this module.

This currently supports the following LCC-Server services::

    conesearch   : cone_search(lcc_server_url, center_ra, center_decl, ...)
    ftsquery     : fulltext_search(lcc_server_url, searchtxt, sesame=False, ...)
    columnsearch : column_search(lcc_server_url, filters, ...)
    xmatch       : xmatch_search(lcc_server_url, file_to_upload, ...

The functions above will download the data products (data table CSVs, light
curve ZIP files) of the search results automatically, or in case the query takes
too long, will return within a configurable timeout. The query information is
cached to `~/.astrobase/lccs`, and can be used to download data products for
long-running queries later.

The functions below support various auxiliary LCC services::

    get-dataset  : get_dataset(lcc_server_url, dataset_id)
    objectinfo   : object_info(lcc_server_url, objectid, collection, ...)
    dataset-list : list_recent_datasets(lcc_server_url, nrecent=25, ...)
    collections  : list_lc_collections(lcc_server_url)

'''

from __future__ import print_function

# put this in here because lccs can be used as a standalone module
__version__ = '0.4.3'


#############
## LOGGING ##
#############

import logging
from astrobase import log_sub, log_fmt, log_date_fmt

DEBUG = False
if DEBUG:
    level = logging.DEBUG
else:
    level = logging.INFO
LOGGER = logging.getLogger(__name__)
logging.basicConfig(
    level=level,
    style=log_sub,
    format=log_fmt,
    datefmt=log_date_fmt,
)

LOGDEBUG = LOGGER.debug
LOGINFO = LOGGER.info
LOGWARNING = LOGGER.warning
LOGERROR = LOGGER.error
LOGEXCEPTION = LOGGER.exception


# get the correct datetime bits
try:
    from datetime import datetime, timezone
    utc = timezone.utc
except Exception:
    from datetime import datetime, timedelta, tzinfo

    # we'll need to instantiate a tzinfo object because py2.7's datetime<commit_msg>lccs: fix log formatting bits<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# lccs.py - <NAME> (<EMAIL>) - Aug 2018
# License: MIT - see LICENSE for the full text.

'''This contains functions to search for objects and get light curves from a
Light Curve Collection server (https://github.com/waqasbhatti/lcc-server) using
its HTTP API.

The LCC-Server requires an API key to access most services. The service
functions in this module will automatically acquire an anonymous user API key on
first use (and upon API key expiry afterwards). If you sign up for an LCC-Server
user account, you can import the API key generated for that account on the user
home page. To do this, use the import_apikey function in this module.

This currently supports the following LCC-Server services::

    conesearch   : cone_search(lcc_server_url, center_ra, center_decl, ...)
    ftsquery     : fulltext_search(lcc_server_url, searchtxt, sesame=False, ...)
    columnsearch : column_search(lcc_server_url, filters, ...)
    xmatch       : xmatch_search(lcc_server_url, file_to_upload, ...

The functions above will download the data products (data table CSVs, light
curve ZIP files) of the search results automatically, or in case the query takes
too long, will return within a configurable timeout. The query information is
cached to `~/.astrobase/lccs`, and can be used to download data products for
long-running queries later.

The functions below support various auxiliary LCC services::

    get-dataset  : get_dataset(lcc_server_url, dataset_id)
    objectinfo   : object_info(lcc_server_url, objectid, collection, ...)
    dataset-list : list_recent_datasets(lcc_server_url, nrecent=25, ...)
    collections  : list_lc_collections(lcc_server_url)

'''

from __future__ import print_function

# put this in here because lccs can be used as a standalone module
__version__ = '0.4.3'


#############
## LOGGING ##
#############

import logging

# the basic logging styles common to all astrobase modules
log_sub = '{'
log_fmt = '[{levelname:1.1} {asctime} {module}:{lineno}] {message}'
log_date_fmt = '%y%m%d %H:%M:%S'

DEBUG = False
if DEBUG:
    level = logging.DEBUG
else:
    level = logging.INFO
LOGGER = logging.getLogger(__name__)
logging.basicConfig(
    level=level,
    style=log_sub,
    format=log_fmt,
    datefmt=log_date_fmt,
)

LOGDEBUG = LOGGER.debug
LOGINFO = LOGGER.info
LOGWARNING = LOGGER.warning
LOGERROR = LOGGER.error
LOGEXCEPTION = LOGGER.exception


# get the correct datetime bits
try:
    from datetime import datetime, timezone
    utc = timezone.utc
except Exception:
    from datetime import datetime, timedelta, tzinfo

    # we'll need to instantiate a tzinfo object because py2.7's datetime
{'fraction_non_alphanumeric': 0.08907721280602636, 'fraction_numerical': 0.004896421845574388, 'mean_word_length': 4.206862745098039, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5869452', 'n_tokens_mistral': 1628, 'n_tokens_neox': 1574, 'n_words': 585}