<commit_before>#!/usr/bin/python3
# 
# Copyright 2016 <NAME>  <contact[at]nich<EMAIL>>
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 

import os
import json
import base64
import requests
import datetime
import hashlib


class FauxapiLibException(Exception):
    pass


class FauxapiLib:

    host = None
    proto = None
    apikey = None
    apisecret = None
    use_snakeoil_https = None

    def __init__(self, host, apikey, apisecret, use_verified_https=False):
        self.host = host
        self.proto = 'https'
        self.base_url = 'fauxapi/v1'
        self.apikey = apikey
        self.apisecret = apisecret
        self.use_verified_https = use_verified_https
        if not self.use_verified_https:
            requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)

    def config_get(self, section=None):
        res = self._api_request('GET', 'config_get')
        if res.status_code != 200:
            raise FauxapiLibException('unable to complete config_get() request', json.loads(res.text))
        else:
            config = json.loads(res.text)
        if section is None:
            return config['data']['config']
        elif section in config['data']['config']:
            return config['data']['config'][section]
        raise FauxapiLibException('unable to complete config_get request, section is unknown', section)

    def config_set(self, config_user, section=None):
        if section is None:
            config = config_user
        else:
            config = self.config_get(section=None)
            config[section] = config_user
        res = self._api_request('POST', 'config_set', data=json.dumps(config))
        if res.status_code != 200:
            raise FauxapiLibException('unable to complete config_set() request', json.loads(res.text))
        return json.loads(res.text)

    def config_reload(self):
        res = self._api_request('GET', 'config_reload')
        if res.status_code != 200:
            raise FauxapiLibException('unable to complete config_reload() request', json.loads(res.text))
        return json.loads(res.text)

    def config_backup(self):
        res = self._api_request('GET', 'config_backup')
        if res.status_code != 200:
            raise FauxapiLibException('unable to complete system_reboot() request', json.loads(res.text))
        return json.loads(res.text)

    def config_backup_list(self):
        pass<commit_msg>added missing config_backup_list() function to the Python library<commit_after>#!/usr/bin/python3
# 
# Copyright 2016 <NAME>  <<EMAIL>[at]<EMAIL>>
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 

import os
import json
import base64
import requests
import datetime
import hashlib


class FauxapiLibException(Exception):
    pass


class FauxapiLib:

    host = None
    proto = None
    apikey = None
    apisecret = None
    use_snakeoil_https = None

    def __init__(self, host, apikey, apisecret, use_verified_https=False):
        self.host = host
        self.proto = 'https'
        self.base_url = 'fauxapi/v1'
        self.apikey = apikey
        self.apisecret = apisecret
        self.use_verified_https = use_verified_https
        if not self.use_verified_https:
            requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)

    def config_get(self, section=None):
        res = self._api_request('GET', 'config_get')
        if res.status_code != 200:
            raise FauxapiLibException('unable to complete config_get() request', json.loads(res.text))
        else:
            config = json.loads(res.text)
        if section is None:
            return config['data']['config']
        elif section in config['data']['config']:
            return config['data']['config'][section]
        raise FauxapiLibException('unable to complete config_get request, section is unknown', section)

    def config_set(self, config_user, section=None):
        if section is None:
            config = config_user
        else:
            config = self.config_get(section=None)
            config[section] = config_user
        res = self._api_request('POST', 'config_set', data=json.dumps(config))
        if res.status_code != 200:
            raise FauxapiLibException('unable to complete config_set() request', json.loads(res.text))
        return json.loads(res.text)

    def config_reload(self):
        res = self._api_request('GET', 'config_reload')
        if res.status_code != 200:
            raise FauxapiLibException('unable to complete config_reload() request', json.loads(res.text))
        return json.loads(res.text)

    def config_backup(self):
        res = self._api_request('GET', 'config_backup')
        if res.status_code != 200:
            raise FauxapiLibException('unable to complete system_reboot() request', json.loads(res.text))
        return json.loads(res.text)

    def config_backup_list(self):
        res = self._api_request('GET', 'config_backup_list')
        if res.status_code != 200:
            raise FauxapiLibException('unable to complete config_backup_list() request', json.loads(res.text))
        return json.loads(res.text)
{'fraction_non_alphanumeric': 0.09674298613350532, 'fraction_numerical': 0.008868107062237987, 'mean_word_length': 3.0542483660130717, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7638480', 'n_tokens_mistral': 1824, 'n_tokens_neox': 1773, 'n_words': 502}