MCPcopy
hub / github.com/deepspeedai/DeepSpeed / get_header_c

Function get_header_c

scripts/replace_copyright.py:102–128  ·  view source on GitHub ↗
(fp)

Source from the content-addressed store, hash-verified

100
101
102def get_header_c(fp):
103 with open(fp, "r") as f:
104 lines = iter(l for l in f.readlines())
105
106 header = []
107 rest = []
108 in_multiline = False
109
110 while (l := next(lines, None)) is not None:
111 l = l.strip()
112 if l.startswith(C_ML_OPEN):
113 # Detected multiline comment
114 if not l.endswith(C_ML_CLOSE):
115 # multiline comment not closed on same line
116 in_multiline = True
117 elif l.endswith(C_ML_CLOSE):
118 # Ended a multiline comment
119 in_multiline = False
120 elif not in_multiline or l.startswith(C_SL_COMMENT) or l.isspace():
121 # Not in a comment
122 rest += [l + "\n"]
123 break
124 header.append(l)
125
126 rest += list(lines)
127
128 return header, rest
129
130
131def get_header_bash(fp):

Callers 1

mainFunction · 0.85

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…