<commit_before>import re
import os
lastNum = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+')

   
def title(t):
	print("\n---------------------------------")
	print(t)
	print("---------------------------------")

   
def cmd(c):
	print("\n" + c)
	os.system(c)		   
   

def increment(s):
    """ look for the last sequence of number(s) in a string and increment """
    m = lastNum.search(s)
    if m:
        next = str(int(m.group(1))+1)
        start, end = m.span(1)
        s = s[:max(end-len(next), start)] + next + s[end:]
    return s, str(next)


def lvgl_clone():
	title("lvgl: Clone")
	cmd("git clone https://github.com/littlevgl/lvgl.git")
	os.chdir("./lvgl")
	cmd("git co master") 

def lvgl_update_version():
	title("lvgl: Update version number")

	f = open("./src/lv_version.h", "r")
		  
	outbuf = ""
	major_ver = -1
	minor_ver = -1
	patch_ver = -1
		  
	for i in f.read().splitlines():
		r = re.search(r'^#define LVGL_VERSION_MAJOR ', i)
		if r: 
		  m = lastNum.search(i)
		  if m: major_ver = m.group(1)

		r = re.search(r'^#define LVGL_VERSION_MINOR ', i)
		if r: 
		  m = lastNum.search(i)
		  if m: minor_ver = m.group(1)
		  
		r = re.search(r'^#define LVGL_VERSION_PATCH ', i)
		if r: 
		  i, patch_ver = increment(i)
		 
		  
		r = re.search(r'^#define LVGL_VERSION_INFO ', i)
		if r: 
		  i = "#define LVGL_VERSION_INFO \"\""
		   
		outbuf += i + '\n'
	 
	f.close()

	f = open("./src/lv_version", "w")
		  
	f.write(outbuf)
	f.close()
    
	s = "v" + str(major_ver) + "." + str(minor_ver) + "." + str(patch_ver)
	print("New version:" + s)
	return s

<commit_msg>release_patch.py: fix incrementing version number<commit_after>import re
import os
lastNum = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+')

   
def title(t):
	print("\n---------------------------------")
	print(t)
	print("---------------------------------")

   
def cmd(c):
	print("\n" + c)
	os.system(c)		   
   

def increment(s):
    """ look for the last sequence of number(s) in a string and increment """
    m = lastNum.search(s)
    if m:
        next = str(int(m.group(1))+1)
        start, end = m.span(1)
        s = s[:max(end-len(next), start)] + next + s[end:]
    return s, str(next)


def lvgl_clone():
	title("lvgl: Clone")
	cmd("git clone https://github.com/littlevgl/lvgl.git")
	os.chdir("./lvgl")
	cmd("git co master") 

def lvgl_update_version():
	title("lvgl: Update version number")

	f = open("./src/lv_version.h", "r")
		  
	outbuf = ""
	major_ver = -1
	minor_ver = -1
	patch_ver = -1
		  
	for i in f.read().splitlines():
		r = re.search(r'^#define LVGL_VERSION_MAJOR ', i)
		if r: 
		  m = lastNum.search(i)
		  if m: major_ver = m.group(1)

		r = re.search(r'^#define LVGL_VERSION_MINOR ', i)
		if r: 
		  m = lastNum.search(i)
		  if m: minor_ver = m.group(1)
		  
		r = re.search(r'^#define LVGL_VERSION_PATCH ', i)
		if r: 
		  i, patch_ver = increment(i)
		 
		  
		r = re.search(r'^#define LVGL_VERSION_INFO ', i)
		if r: 
		  i = "#define LVGL_VERSION_INFO \"\""
		   
		outbuf += i + '\n'
	 
	f.close()

	f = open("./src/lv_version.h", "w")
		  
	f.write(outbuf)
	f.close()
    
	s = "v" + str(major_ver) + "." + str(minor_ver) + "." + str(patch_ver)
	print("New version:" + s)
	return s


{'fraction_non_alphanumeric': 0.2237171464330413, 'fraction_numerical': 0.0050062578222778474, 'mean_word_length': 2.3336809176225235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5362079', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1291, 'n_words': 282}