Illyoung Choi | a9d2c2c | 2019-07-12 13:29:42 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | # Copyright 2019-present Open Networking Foundation |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | """ |
| 18 | Utils |
| 19 | """ |
| 20 | |
| 21 | import string |
| 22 | import random |
| 23 | |
| 24 | |
| 25 | class NoopLogger(object): |
| 26 | def __init__(self): |
| 27 | pass |
| 28 | |
| 29 | def info(self, *args): |
| 30 | pass |
| 31 | |
| 32 | def debug(self, *args): |
| 33 | pass |
| 34 | |
| 35 | def error(self, *args): |
| 36 | pass |
| 37 | |
| 38 | def warn(self, *args): |
| 39 | pass |
| 40 | |
| 41 | |
| 42 | def get_noop_logger(): |
| 43 | return NoopLogger() |
| 44 | |
| 45 | |
| 46 | def gen_id(size=6, chars=string.ascii_uppercase + string.digits): |
| 47 | return ''.join(random.choice(chars) for _ in range(size)) |
| 48 | |
| 49 | |
| 50 | def gen_seq_id(): |
| 51 | return random.randint(1010, 101010) |