-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpydatatest.py
More file actions
76 lines (52 loc) · 1.59 KB
/
pydatatest.py
File metadata and controls
76 lines (52 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Test of router list and element manipulation
# Using Python3
from datetime import datetime
import logging
logging.warning('Test Warning #####')
vendors = ['juniper', 'cisco', 'arista', 'citrix', 'NGINX', 'timetra']
switches = ['N5K', 'N9K', 'N7K','N3K', '4507','6500','7050X']
# Various list print methods
print('\nVENDORS - no list manipulation\n')
print(vendors)
print('\nVENDORS - all members\n')
print(vendors[0:])
print('\nVENDORS - print just the last member (syntax disappears)\n')
print(vendors[-1])
# Iterating the list removes syntax and prints each item on separate line
print('\nVENDORS - Iterate the list (once with and without .title\n')
for vendor in vendors:
print(vendor)
print(vendor.title())
if 'Cisco' not in vendors:
print('Cisco is missing. Invalid list.')
# sort and then print along with total count
vendors.sort()
currentTime = datetime.now()
# currentTimeshort = datetime.strptime(currentTime, "%Y-%m-%d")
print('\nVENDORS - default sort\n')
print(currentTime)
print(vendors)
print('\nTotal Count: ',len(vendors))
# copy list for future mutation
vendorcopy = vendors[:]
# now validate the copy
print('\nVENDORS - copy default sort\n')
print(vendorcopy)
# print a value range
print('\nPrinting values\n\n')
sum=0
for value in range(1,5):
print(value)
sum=sum+value
print('\nTotal ')
print(sum)
# Now move to a vendor-product dictionary
cisco_models = {
'Nexus': 'Data Center Router',
'Catalyst': 'Campus Router',
'ASR': 'Edge Router',
}
print('\nPrinting Cisco Categories\n')
for key, value in cisco_models.items():
print('\n' + key + ' Line: ' + value)
print('\nEND\n')