Пример #1
0
# Copyright 2020 Alex Woroschilow ([email protected])
#
# 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.
import hexdi

console = hexdi.resolve('console')
if not console: raise Exception('Console service not found')


@console.task(
    name=['search', 'find', 'lookup'],
    description=
    "<string>\tFind an application in the repository using the given string as an application name"
)
@hexdi.inject('config', 'apprepo')
def main(options=None, args=None, config=None, apprepo=None):
    from bs4 import BeautifulSoup

    def strip_tags(html=None):
        if html is None: return None

        soup = BeautifulSoup(html, "html5lib")
        [x.extract() for x in soup.find_all('script')]
Пример #2
0
class OptionParser(optparse.OptionParser):
    def __init__(self):
        super(OptionParser, self).__init__()

        self.add_option("--loglevel",
                        default=logging.INFO,
                        dest="loglevel",
                        help="Logging level")
        self.add_option("--gui",
                        default='qt5',
                        dest="gui",
                        help="Interface type")

        configfile = '~/.config/apprepo/default.conf'
        self.add_option(
            "--config",
            default=os.path.expanduser(configfile),
            dest="config",
            help="Config file location, default: {}".format(configfile))


if __name__ == "__main__":
    parser = hexdi.resolve('optparse')
    (options, args) = parser.parse_args()

    log_format = '[%(relativeCreated)d][%(name)s] %(levelname)s - %(message)s'
    logging.basicConfig(level=options.loglevel, format=log_format)

    application = application.Application(options, args)
    sys.exit(application.exec_(options, args))