inital = transfer git to git2

This commit is contained in:
hsafaei
2024-09-14 10:32:42 +03:30
commit e991cc84cb
53 changed files with 8472 additions and 0 deletions
@@ -0,0 +1,112 @@
import json
import requests
from config_base import *
import requests
from bs4 import BeautifulSoup
from html import escape
import json
from decimal import Decimal
import datetime
from config_base import *
from general_functions import *
# موقت
# این برنامه موقتا بخاطر اصلاح داده اجرا شد، اگر از ابتدا انتقال داده انجام شود این بخش خودکار انجام خواهد شد
cursor, cnxn = create_cursor()
# Does quasi the same things as json.loads from here: https://pypi.org/project/dynamodb-json/
class JSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, Decimal):
return float(obj)
return json.JSONEncoder.default(self, obj)
#نکته : برای مقررات هیچ موردی نبود که جدولی باشد
query = '''
SELECT s.ID as sectionId
,isnull(lss2.CAPTION,'') as qanon_etebar -- lwLawSectionStatus_table: ... منسوخه، معتبر، اصلاحی، موقت و
FROM [Qavanin].[dbo].[lwSection] s
left join lwLaw l on s.F_LWLAWID = l.ID
left join lwLawSectionStatus lss2 on lss2.id= l.[F_CMBASETABLEID_LASTSTATUS]
where l.[ISREGULATION] = 1
'''
cursor.execute(query)
url = BASE_URL + "repo/majles/rgsection/multi/update"
dict_topic = json.loads(open("list_LWTopic.json").read())
headers = HEADERS
bulk_count = 0
bulk_data = []
previd = ''
ref_state_array = []
t1= datetime.datetime.now()
print(t1)
i = 0
while 1:
# print(i)
i=i+1
row = cursor.fetchone()
if not row:
break
# if i > 3:
# break
# print(row.sectionId)
# try:
# soup = BeautifulSoup(row.sectionText, "html.parser")
# text = soup.get_text("\n", strip=True)
# # text = removeHtmlNoTableTag(row.sectionText) # خطا داره
# except Exception as e:
# text = row.sectionText
# text = normalYehKe(text)
eid='qs'+ str(row.sectionId)
qanon_etebar = ''
if row.qanon_etebar :
qanon_etebar = row.qanon_etebar
data={
'id' : eid,
'qanon_etebar' : qanon_etebar
}
if bulk_count > 500:
print('=' * 10 )
print(str(i)+ ', id=' + eid)
payload = json.dumps(bulk_data, cls=JSONEncoder) #Works!
response = requests.request("POST", url, headers=headers, data=payload)
bulk_data = []
bulk_count =0
# print(response.text)
#print(row.txt)
bulk_data.append(data)
bulk_count +=1
print(bulk_count)
if bulk_count >= 1:
payload = json.dumps(bulk_data, cls=JSONEncoder) #Works!
response = requests.request("POST", url, headers=headers, data=payload)
print(response)
# print(response.text )
cursor.close()
cnxn.close()
print('end success')
t2= datetime.datetime.now()
print(t2-t1)