rda-python-metrics 1.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rda-python-metrics might be problematic. Click here for more details.
- rda_python_metrics-1.0.4/LICENSE +21 -0
- rda_python_metrics-1.0.4/MANIFEST.in +18 -0
- rda_python_metrics-1.0.4/PKG-INFO +18 -0
- rda_python_metrics-1.0.4/README.md +1 -0
- rda_python_metrics-1.0.4/pyproject.toml +65 -0
- rda_python_metrics-1.0.4/setup.cfg +4 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/PgIPInfo.py +188 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/PgView.py +782 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/__init__.py +1 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/fillawsusage.py +282 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/fillawsusage.usg +17 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/fillcodusage.py +247 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/fillcodusage.usg +21 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/fillcountry.py +79 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/fillendtime.py +93 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/fillglobususage.py +287 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/fillglobususage.usg +17 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/fillipinfo.py +185 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/fillipinfo.usg +18 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/filloneorder.py +155 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/filloneorder.usg +41 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/fillrdadb.py +151 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/fillrdadb.usg +32 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/filltdsusage.py +289 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/filltdsusage.usg +17 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/filluser.py +216 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/filluser.usg +16 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/logarch.py +359 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/logarch.usg +27 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/pgperson.py +72 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/pgusername.py +50 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewallusage.py +350 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewallusage.usg +198 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewcheckusage.py +289 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewcheckusage.usg +185 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewcodusage.py +314 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewcodusage.usg +184 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewordusage.py +340 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewordusage.usg +224 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewrqstusage.py +362 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewrqstusage.usg +217 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewtdsusage.py +323 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewtdsusage.usg +191 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewwebfile.py +294 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewwebfile.usg +212 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewwebusage.py +371 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics/viewwebusage.usg +211 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics.egg-info/PKG-INFO +18 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics.egg-info/SOURCES.txt +52 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics.egg-info/dependency_links.txt +1 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics.egg-info/entry_points.txt +22 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics.egg-info/requires.txt +2 -0
- rda_python_metrics-1.0.4/src/rda_python_metrics.egg-info/top_level.txt +1 -0
- rda_python_metrics-1.0.4/tests/test_metrics.py +6 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 National Center for Atmospheric Research
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
include src/rda_python_metrics/fillawsusage.usg
|
|
2
|
+
include src/rda_python_metrics/fillcodusage.usg
|
|
3
|
+
include src/rda_python_metrics/fillglobususage.usg
|
|
4
|
+
include src/rda_python_metrics/fillipinfo.usg
|
|
5
|
+
include src/rda_python_metrics/filloneorder.usg
|
|
6
|
+
include src/rda_python_metrics/fillrdadb.usg
|
|
7
|
+
include src/rda_python_metrics/filltdsusage.usg
|
|
8
|
+
include src/rda_python_metrics/filluser.usg
|
|
9
|
+
include src/rda_python_metrics/logarch.usg
|
|
10
|
+
include src/rda_python_metrics/viewallusage.usg
|
|
11
|
+
include src/rda_python_metrics/viewcheckusage.usg
|
|
12
|
+
include src/rda_python_metrics/viewcodusage.usg
|
|
13
|
+
include src/rda_python_metrics/viewordusage.usg
|
|
14
|
+
include src/rda_python_metrics/viewrqstusage.usg
|
|
15
|
+
include src/rda_python_metrics/viewtdsusage.usg
|
|
16
|
+
include src/rda_python_metrics/viewwebfile.usg
|
|
17
|
+
include src/rda_python_metrics/viewallusage.usg
|
|
18
|
+
include src/rda_python_metrics/viewwebusage.usg
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rda_python_metrics
|
|
3
|
+
Version: 1.0.4
|
|
4
|
+
Summary: RDA Python Package to gather and view data usage metrics
|
|
5
|
+
Author-email: Zaihua Ji <zji@ucar.edu>
|
|
6
|
+
Project-URL: Homepage, https://github.com/NCAR/rda-python-metrics
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Requires-Python: >=3.7
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: rda_python_common
|
|
15
|
+
Requires-Dist: rda_python_setuid
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
RDA Python Package to gather and view data usage metrics.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
RDA Python Package to gather and view data usage metrics.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"setuptools>=61.0",
|
|
4
|
+
]
|
|
5
|
+
build-backend = "setuptools.build_meta"
|
|
6
|
+
|
|
7
|
+
[project]
|
|
8
|
+
name = "rda_python_metrics"
|
|
9
|
+
version = "1.0.4"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name="Zaihua Ji", email="zji@ucar.edu" },
|
|
12
|
+
]
|
|
13
|
+
description = "RDA Python Package to gather and view data usage metrics"
|
|
14
|
+
readme = "README.md"
|
|
15
|
+
requires-python = ">=3.7"
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Development Status :: 5 - Production/Stable",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"rda_python_common",
|
|
24
|
+
"rda_python_setuid",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[tool.setuptools]
|
|
28
|
+
include-package-data = true
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.packages.find]
|
|
31
|
+
where = ["src"]
|
|
32
|
+
|
|
33
|
+
[tool.setuptools.package-data]
|
|
34
|
+
"rda_python_metrics" = [
|
|
35
|
+
"logarch.usg", "fillawsusage.usg", "fillcodusage.usg", "fillglobususage.usg",
|
|
36
|
+
"fillipinfo.usg", "filloneorder.usg", "fillrdadb.usg", "filltdsusage.usg",
|
|
37
|
+
"viewallusage.usg", "viewcheckusage.usg", "viewcodusage.usg", "viewordusage.usg",
|
|
38
|
+
"viewrqstusage.usg", "viewtdsusage.usg", "viewwebfile.usg", "viewwebusage.usg"
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
"Homepage" = "https://github.com/NCAR/rda-python-metrics"
|
|
43
|
+
|
|
44
|
+
[project.scripts]
|
|
45
|
+
"logarch.py" = "rda_python_metrics.logarch:main"
|
|
46
|
+
"fillawsusage" = "rda_python_metrics.fillaswusage:main"
|
|
47
|
+
"fillcodusage" = "rda_python_metrics.fillcodusage:main"
|
|
48
|
+
"fillcountry" = "rda_python_metrics.fillcountry:main"
|
|
49
|
+
"fillendtime" = "rda_python_metrics.fillendtime:main"
|
|
50
|
+
"fillglobususage" = "rda_python_metrics.fillglobususage:main"
|
|
51
|
+
"fillipinfo" = "rda_python_metrics.fillipinfo:main"
|
|
52
|
+
"filloneorder" = "rda_python_metrics.filloneorder:main"
|
|
53
|
+
"fillrdadb" = "rda_python_metrics.fillrdadb:main"
|
|
54
|
+
"filltdsusage" = "rda_python_metrics.tdsusage:main"
|
|
55
|
+
"filluser" = "rda_python_metrics.filluser:main"
|
|
56
|
+
"pgperson" = "rda_python_metrics.pgperson:main"
|
|
57
|
+
"pgusername" = "rda_python_metrics.pgusername:main"
|
|
58
|
+
"viewallusage" = "rda_python_metrics.viewallusage:main"
|
|
59
|
+
"viewcheckusage" = "rda_python_metrics.viewcheckusage:main"
|
|
60
|
+
"viewcodusage" = "rda_python_metrics.viewcodusage:main"
|
|
61
|
+
"viewordusage" = "rda_python_metrics.viewordusage:main"
|
|
62
|
+
"viewrqstusage" = "rda_python_metrics.viewrqstusage:main"
|
|
63
|
+
"viewtdsusage" = "rda_python_metrics.viewtdsusage:main"
|
|
64
|
+
"viewwebfile" = "rda_python_metrics.viewwebfile:main"
|
|
65
|
+
"viewwebusage" = "rda_python_metrics.viewwebusage:main"
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
#
|
|
2
|
+
###############################################################################
|
|
3
|
+
#
|
|
4
|
+
# Title : PgIPInfo
|
|
5
|
+
# Author : Zaihua Ji, zji@ucar.edu
|
|
6
|
+
# Date : 08/22/2023
|
|
7
|
+
# 2025-03-26 transferred to package rda_python_metrics from
|
|
8
|
+
# https://github.com/NCAR/rda-shared-library.git
|
|
9
|
+
# Purpose : python module to retrieve ip info from ipinfo
|
|
10
|
+
# or geoip2 modules
|
|
11
|
+
#
|
|
12
|
+
# Github : https://github.com/NCAR/rda-python-common.git
|
|
13
|
+
#
|
|
14
|
+
###############################################################################
|
|
15
|
+
#
|
|
16
|
+
import geoip2.database as geodb
|
|
17
|
+
import ipinfo
|
|
18
|
+
import socket
|
|
19
|
+
from rda_python_common import PgLOG
|
|
20
|
+
from rda_python_common import PgDBI
|
|
21
|
+
from rda_python_common import PgUtil
|
|
22
|
+
|
|
23
|
+
IPINFO = {
|
|
24
|
+
'TOKEN' : 'b2a67fdd1a9ba3',
|
|
25
|
+
'DBFILE' : PgLOG.PGLOG['DSSHOME'] + '/dssdb/GeoLite2-City.mmdb',
|
|
26
|
+
'CDATE' : PgUtil.curdate(),
|
|
27
|
+
'IPUPDT' : 0,
|
|
28
|
+
'IPADD' : 0
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
IPDB = None
|
|
32
|
+
G2DB = None
|
|
33
|
+
IPRECS = {}
|
|
34
|
+
COUNTRIES = {}
|
|
35
|
+
|
|
36
|
+
#
|
|
37
|
+
# Get country token name for given two-character domain id
|
|
38
|
+
#
|
|
39
|
+
def get_country_name_code(dm):
|
|
40
|
+
|
|
41
|
+
if dm not in COUNTRIES:
|
|
42
|
+
pgrec = PgDBI.pgget('countries', 'token', "domain_id = '{}'".format(dm))
|
|
43
|
+
COUNTRIES[dm] = pgrec['token'] if pgrec else 'Unknown'
|
|
44
|
+
return COUNTRIES[dm]
|
|
45
|
+
|
|
46
|
+
def get_country_record_code(cname, kname = None):
|
|
47
|
+
|
|
48
|
+
name = cname[kname] if kname else cname
|
|
49
|
+
name = name.replace(' ', '.').upper() if name else 'UNITED.STATES'
|
|
50
|
+
if name == 'CHINA': name = 'P.R.CHINA'
|
|
51
|
+
|
|
52
|
+
return name
|
|
53
|
+
|
|
54
|
+
def set_ipinfo_database():
|
|
55
|
+
|
|
56
|
+
global IPDB
|
|
57
|
+
try:
|
|
58
|
+
IPDB = ipinfo.getHandler(IPINFO['TOKEN'])
|
|
59
|
+
except Exception as e:
|
|
60
|
+
PgLOG.pglog('ipinfo: ' + str(e), PgLOG.LGEREX)
|
|
61
|
+
|
|
62
|
+
#
|
|
63
|
+
# get a ipinfo record for given ip address
|
|
64
|
+
#
|
|
65
|
+
def get_ipinfo_record(ip):
|
|
66
|
+
|
|
67
|
+
if not IPDB: set_ipinfo_database()
|
|
68
|
+
try:
|
|
69
|
+
iprec = IPDB.getDetails(ip).all
|
|
70
|
+
if 'hostname' not in iprec:
|
|
71
|
+
PgLOG.pglog("ipinfo: {} - ip address is not in the database".format(ip), PgLOG.LOGERR)
|
|
72
|
+
return None
|
|
73
|
+
except Exception as e:
|
|
74
|
+
PgLOG.pglog("ipinfo: {} - {}".format(ip, str(e)), PgLOG.LOGWRN)
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
record = {'ip' : ip, 'stat_flag' : 'A', 'hostname' : ip}
|
|
78
|
+
if 'hostname' in iprec:
|
|
79
|
+
record['hostname'] = iprec['hostname']
|
|
80
|
+
record['org_type'] = PgDBI.get_org_type(None, record['hostname'])
|
|
81
|
+
record['lat'] = float(iprec['latitude']) if iprec['latitude'] else 0
|
|
82
|
+
record['lon'] = float(iprec['longitude']) if iprec['longitude'] else 0
|
|
83
|
+
if 'org' in iprec: record['org_name'] = iprec['org']
|
|
84
|
+
record['country'] = get_country_record_code(iprec, 'country_name')
|
|
85
|
+
if 'city' in iprec: record['city'] = PgLOG.convert_chars(iprec['city'])
|
|
86
|
+
if 'postal' in iprec: record['postal'] = iprec['postal']
|
|
87
|
+
record['timezone'] = iprec['timezone']
|
|
88
|
+
|
|
89
|
+
return record
|
|
90
|
+
|
|
91
|
+
def set_geoip2_database():
|
|
92
|
+
|
|
93
|
+
global G2DB
|
|
94
|
+
try:
|
|
95
|
+
G2DB = geodb.Reader(IPINFO['DBFILE'])
|
|
96
|
+
except Exception as e:
|
|
97
|
+
PgLOG.pglog("geoip2: " + str(e), PgLOG.LGEREX)
|
|
98
|
+
|
|
99
|
+
#
|
|
100
|
+
# get a geoip2 record for given ip address
|
|
101
|
+
#
|
|
102
|
+
def get_geoip2_record(ip):
|
|
103
|
+
|
|
104
|
+
if not G2DB: set_geoip2_database()
|
|
105
|
+
try:
|
|
106
|
+
city = G2DB.city(ip)
|
|
107
|
+
except Exception as e:
|
|
108
|
+
PgLOG.pglog("geoip2: {} - {}".format(ip, str(e)), PgLOG.LOGWRN)
|
|
109
|
+
return None
|
|
110
|
+
|
|
111
|
+
record = {'ip' : ip, 'stat_flag' : 'M'}
|
|
112
|
+
record['lat'] = float(city.location.latitude) if city.location.latitude else 0
|
|
113
|
+
record['lon'] = float(city.location.longitude) if city.location.longitude else 0
|
|
114
|
+
record['country'] = get_country_name_code(city.country.name)
|
|
115
|
+
record['city'] = PgLOG.convert_chars(city.city.name)
|
|
116
|
+
record['postal'] = city.postal.code
|
|
117
|
+
record['timezone'] = city.location.time_zone
|
|
118
|
+
record['hostname'] = ip
|
|
119
|
+
record['org_type'] = '-'
|
|
120
|
+
|
|
121
|
+
try:
|
|
122
|
+
hostrec = socket.gethostbyaddr(ip)
|
|
123
|
+
except Exception as e:
|
|
124
|
+
PgLOG.pglog("socket: {} - {}".format(ip, str(e)), PgLOG.LOGWRN)
|
|
125
|
+
return record
|
|
126
|
+
record['hostname'] = hostrec[1][0] if hostrec[1] else hostrec[0]
|
|
127
|
+
record['org_type'] = PgDBI.get_org_type(None, record['hostname'])
|
|
128
|
+
|
|
129
|
+
return record
|
|
130
|
+
|
|
131
|
+
#
|
|
132
|
+
# update wuser.email for hostname changed
|
|
133
|
+
#
|
|
134
|
+
def update_wuser_email(nhost, ohost):
|
|
135
|
+
|
|
136
|
+
pgrec = PgDBI.pgget('wuser', 'widx', "email = 'unknown@{}'".format(ohost))
|
|
137
|
+
if pgrec: PgDBI.pgexec("UPDATE wuser SET email = 'unknown@{}' WHERE widx = {}".format(nhost, pgrec['widx']))
|
|
138
|
+
|
|
139
|
+
#
|
|
140
|
+
# update a ipinfo record; add a new one if not exists yet
|
|
141
|
+
#
|
|
142
|
+
def update_ipinfo_record(record, pgrec = None):
|
|
143
|
+
|
|
144
|
+
tname = 'ipinfo'
|
|
145
|
+
cnd = "ip = '{}'".format(record['ip'])
|
|
146
|
+
if not pgrec: pgrec = PgDBI.pgget(tname, '*', cnd)
|
|
147
|
+
if pgrec:
|
|
148
|
+
nrec = get_update_record(record, pgrec)
|
|
149
|
+
if 'hostname' in nrec: update_wuser_email(nrec['hostname'], pgrec['hostname'])
|
|
150
|
+
ret = PgDBI.pgupdt(tname, nrec, cnd) if nrec else 0
|
|
151
|
+
IPINFO['IPUPDT'] += ret
|
|
152
|
+
else:
|
|
153
|
+
record['adddate'] = IPINFO['CDATE']
|
|
154
|
+
ret = PgDBI.pgadd(tname, record)
|
|
155
|
+
IPINFO['IPADD'] += ret
|
|
156
|
+
|
|
157
|
+
return ret
|
|
158
|
+
|
|
159
|
+
#
|
|
160
|
+
# set ip info into table ipinfo from python module ipinfo
|
|
161
|
+
# if ipopt is True; otherwise, use module geoip2
|
|
162
|
+
#
|
|
163
|
+
def set_ipinfo(ip, ipopt = False):
|
|
164
|
+
|
|
165
|
+
if ip in IPRECS:
|
|
166
|
+
pgrec = IPRECS[ip]
|
|
167
|
+
if not pgrec or not ipopt or pgrec['stat_flag'] == 'A': return pgrec
|
|
168
|
+
else:
|
|
169
|
+
pgrec = PgDBI.pgget('ipinfo', '*', "ip = '{}'".format(ip))
|
|
170
|
+
|
|
171
|
+
if not pgrec or ipopt and pgrec['stat_flag'] == 'M':
|
|
172
|
+
record = None if ipopt else get_geoip2_record(ip)
|
|
173
|
+
if not (record and 'hostname' in record): record = get_ipinfo_record(ip)
|
|
174
|
+
if record and update_ipinfo_record(record, pgrec): pgrec = record
|
|
175
|
+
|
|
176
|
+
IPRECS[ip] = pgrec
|
|
177
|
+
return pgrec
|
|
178
|
+
|
|
179
|
+
#
|
|
180
|
+
# compare and return a new record holding fields with different values only
|
|
181
|
+
#
|
|
182
|
+
def get_update_record(nrec, orec):
|
|
183
|
+
|
|
184
|
+
record = {}
|
|
185
|
+
for fld in nrec:
|
|
186
|
+
if nrec[fld] != orec[fld]:
|
|
187
|
+
record[fld] = nrec[fld]
|
|
188
|
+
return record
|