Skip to content

Instantly share code, notes, and snippets.

@riza
Last active December 16, 2020 13:41
Show Gist options
  • Save riza/f5e06ab036ffb4f67d61947bcfc661de to your computer and use it in GitHub Desktop.
Save riza/f5e06ab036ffb4f67d61947bcfc661de to your computer and use it in GitHub Desktop.
Merge edilemeyen çüküşük yaml dosyalarınızdaki headleri çıkarır.
#!/usr/bin/env python
import sys,yaml
def Diff(first, second):
second = set(second)
return [item for item in first if item not in second]
CONFLICT_SPACER = "======="
FILE_PATH = sys.argv[1]
CONFLICT_FILE_CONTENT = open(FILE_PATH, "r").read()
FILE_SPLITTED = CONFLICT_FILE_CONTENT.split(CONFLICT_SPACER)
FILE_LOCAL = FILE_SPLITTED[0].split("\n",2)[2]
FILE_REMOTE = FILE_SPLITTED[1].rsplit("\n",2)[0]
LOCAL_YAML_HEADS = []
REMOTE_YAML_HEADS = []
for key, value in yaml.load(FILE_LOCAL).items():
LOCAL_YAML_HEADS.append(str(key))
for key, value in yaml.load(FILE_REMOTE).items():
REMOTE_YAML_HEADS.append(str(key))
DIFF_HEADS = Diff(REMOTE_YAML_HEADS,LOCAL_YAML_HEADS)
for i in DIFF_HEADS:
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment