diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2019-09-09 18:47:17 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2019-09-09 18:47:17 +0300 |
commit | bbd4c972dd8a6d2721a2af0d6d930684b7fda4e4 (patch) | |
tree | cc14dbef58362ab1cf793612273e27651812b1cd | |
parent | add Travis configuration (diff) | |
download | vk-scripts-bbd4c972dd8a6d2721a2af0d6d930684b7fda4e4.tar.gz vk-scripts-bbd4c972dd8a6d2721a2af0d6d930684b7fda4e4.zip |
normalize line endings
-rw-r--r-- | .gitattributes | 1 | ||||
-rw-r--r-- | bin/show_status.py | 78 |
2 files changed, 40 insertions, 39 deletions
diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/bin/show_status.py b/bin/show_status.py index 74e1ac8..1ca9cb5 100644 --- a/bin/show_status.py +++ b/bin/show_status.py @@ -1,39 +1,39 @@ -# Copyright (c) 2019 Egor Tensin <Egor.Tensin@gmail.com>
-# This file is part of the "VK scripts" project.
-# For details, see https://github.com/egor-tensin/vk-scripts.
-# Distributed under the MIT License.
-
-import argparse, sys
-
-from vk.api import API
-from vk.tracking import StatusTracker
-from vk.tracking.db import Format as DatabaseFormat
-
-def _parse_args(args=None):
- if args is None:
- args = sys.argv[1:]
-
- parser = argparse.ArgumentParser(
- description='Show if people are online/offline.')
-
- parser.add_argument('uids', metavar='UID', nargs='+',
- help='user IDs or "screen names"')
- parser.add_argument('-l', '--log', metavar='PATH', dest='log_path',
- help='set log file path (standard output by default)')
-
- return parser.parse_args(args)
-
-def track_status(uids, log_path=None):
- api = API()
- tracker = StatusTracker(api)
-
- with DatabaseFormat.LOG.open_output_file(log_path) as log_fd:
- log_writer = DatabaseFormat.LOG.create_writer(log_fd)
- tracker.add_database_writer(log_writer)
- tracker.query_status(uids)
-
-def main(args=None):
- track_status(**vars(_parse_args(args)))
-
-if __name__ == '__main__':
- main()
+# Copyright (c) 2019 Egor Tensin <Egor.Tensin@gmail.com> +# This file is part of the "VK scripts" project. +# For details, see https://github.com/egor-tensin/vk-scripts. +# Distributed under the MIT License. + +import argparse, sys + +from vk.api import API +from vk.tracking import StatusTracker +from vk.tracking.db import Format as DatabaseFormat + +def _parse_args(args=None): + if args is None: + args = sys.argv[1:] + + parser = argparse.ArgumentParser( + description='Show if people are online/offline.') + + parser.add_argument('uids', metavar='UID', nargs='+', + help='user IDs or "screen names"') + parser.add_argument('-l', '--log', metavar='PATH', dest='log_path', + help='set log file path (standard output by default)') + + return parser.parse_args(args) + +def track_status(uids, log_path=None): + api = API() + tracker = StatusTracker(api) + + with DatabaseFormat.LOG.open_output_file(log_path) as log_fd: + log_writer = DatabaseFormat.LOG.create_writer(log_fd) + tracker.add_database_writer(log_writer) + tracker.query_status(uids) + +def main(args=None): + track_status(**vars(_parse_args(args))) + +if __name__ == '__main__': + main() |