re.match(pattern, string, flags=0)

If zero or more characters at the beginning of string match the regular expression pattern, return a corresponding MatchObject instance. Return None if the string does not match the pattern; note that this is different from a zero-length match.

Note that even in MULTILINE mode, re.match() will only match at the beginning of the string and not at the beginning of each line.

If you want to locate a match anywhere in string, use search() instead (see also search() vs. match()).


'리눅스 > 스크립트/유틸' 카테고리의 다른 글

[screen/byobu] 윈도우 숫자 바꾸기  (0) 2013.06.29
[파이썬] String 가지고 놀기  (0) 2013.06.04
python, tempfile.mkdtemp  (0) 2013.04.28
python, getopt  (0) 2013.04.21
python, pass statement  (0) 2013.04.17
Posted by code cat
출처:http://docs.python.org/2/library/tempfile.html

tempfile.mkdtemp([suffix=''[, prefix='tmp'[, dir=None]]])

Creates a temporary directory in the most secure manner possible. There are no race conditions in the directory’s creation. The directory is readable, writable, and searchable only by the creating user ID.

The user of mkdtemp() is responsible for deleting the temporary directory and its contents when done with it.

The prefix, suffix, and dir arguments are the same as for mkstemp().

mkdtemp() returns the absolute pathname of the new directory.

New in version 2.3.


tempfile.NamedTemporaryFile([mode='w+b'[, bufsize=-1[, suffix=''[, prefix='tmp'[, dir=None[, delete=True]]]]]])

This function operates exactly as TemporaryFile() does, except that the file is guaranteed to have a visible name in the file system (on Unix, the directory entry is not unlinked). That name can be retrieved from the name attribute of the file object. Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later). If delete is true (the default), the file is deleted as soon as it is closed.

The returned object is always a file-like object whose file attribute is the underlying true file object. This file-like object can be used in a with statement, just like a normal file.

New in version 2.3.

New in version 2.6: The delete parameter.


'리눅스 > 스크립트/유틸' 카테고리의 다른 글

[파이썬] String 가지고 놀기  (0) 2013.06.04
python, regular expression match  (0) 2013.04.28
python, getopt  (0) 2013.04.21
python, pass statement  (0) 2013.04.17
git 저장소 추가 시에 주의 할 점.  (0) 2013.03.24
Posted by code cat

getopt 는 c코딩에 익숙한 유저들을 위해 command line option을 parsing 하기 위해 지원하는 API이다.

정확히 sys.argv에 있는 argument들을 parsing하는데, unix conventions('-' , '--' 들의 차이점등) 들을 지원한다.

getopt는 아래의 두함수를 지원한다.


getopt.getopt(args, options[, long_options])

args = parsing 될 인자 리스트들이며, 실행 프로그램을 제외한다.  sys.argv[1:] 부터 시작되며, 즉 ota_from_target_files -x -d 일 경우, -x부터 시작한다는 말이다. 인자를 필요로 하는 옵션일 경우 : 이 붙는다.

long_options의 경우 '--' 는 옵션 이름에 포함되지 말아야 한다.  인자를 필요로 하는 경우, 인자는 '='뒤에 따라와야 한다.  long option만 받을라면, option 리스트가 비어야 있어야한다.

리턴 값은 두 종류이다.  첫번째는 (option, value)로 이루어진 리스트이며, 두번째는 option을 제외하고 남은 args들이다.  (option, value)의 첫번째 항목은 옵션이며, '-'를 prefix로 가지고 있다.  두번째 항목은 옵션에 해당하는 값이다.


getopt.gnu_getopt(args, options[, long_options])
getopt와 같으며, 대신 GNU style scanning을 지원한다.  즉 옵션 과 옵션이 아닌 인자들을 혼합해 사용 가능하다.


exception getopt.GetoptError알수 없는 옵션이거나, 인자가 필요한 옵션에 인자가 없을 경우 일어난다.   exception getopt.error
GetoptError 와 같으나, backward compatibility를 위해서 존재한다.

'리눅스 > 스크립트/유틸' 카테고리의 다른 글

python, regular expression match  (0) 2013.04.28
python, tempfile.mkdtemp  (0) 2013.04.28
python, pass statement  (0) 2013.04.17
git 저장소 추가 시에 주의 할 점.  (0) 2013.03.24
byobu detached 세션 죽이기  (0) 2013.03.13
Posted by code cat
http://docs.python.org/release/2.5.2/ref/pass.html

6.4 The pass statement

pass_stmt ::= "pass"
Download entire grammar as text.
pass is a null operation -- when it is executed, nothing happens. It is useful as a placeholder when a statement is required syntactically, but no code needs to be executed, for example:

def f(arg): pass # a function that does nothing (yet)

class C: pass # a class with no methods (yet)

iPhone 에서 작성된 글입니다.
Posted by code cat
카테고리 없음2013. 3. 24. 17:17

GGLSurface 도 알아야 한다.  그렇게 특별한 점은 보이지 않는다.


187typedef struct {
188    GGLsizei    version;    // always set to sizeof(GGLSurface)
189    GGLuint     width;      // width in pixels
190    GGLuint     height;     // height in pixels
191    GGLint      stride;     // stride in pixels
192    GGLubyte*   data;       // pointer to the bits
193    GGLubyte    format;     // pixel format
194    GGLubyte    rfu[3];     // must be zero
195    // these values are dependent on the used format
196    union {
197        GGLint  compressedFormat;
198        GGLint  vstride;
199    };
200    void*       reserved;
201} GGLSurface;


Posted by code cat
안드로이드/포팅2013. 3. 24. 16:15

아래는 recovery UI 에 사용되는 GGLContext 의 구조체이다.

204 typedef struct {
205    // immediate rendering
206    void (*pointx)(void *con, const GGLcoord* v, GGLcoord r);
207    void (*linex)(void *con,
208            const GGLcoord* v0, const GGLcoord* v1, GGLcoord width);
209    void (*recti)(void* c, GGLint l, GGLint t, GGLint r, GGLint b);
210    void (*trianglex)(void* c,
211            GGLcoord const* v0, GGLcoord const* v1, GGLcoord const* v2);
212
213    // scissor
214    void (*scissor)(void* c, GGLint x, GGLint y, GGLsizei width, GGLsizei height);
215
216    // Set the textures and color buffers
217    void (*activeTexture)(void* c, GGLuint tmu);
218    void (*bindTexture)(void* c, const GGLSurface* surface);
219    void (*colorBuffer)(void* c, const GGLSurface* surface);
220    void (*readBuffer)(void* c, const GGLSurface* surface);
221    void (*depthBuffer)(void* c, const GGLSurface* surface);
222    void (*bindTextureLod)(void* c, GGLuint tmu, const GGLSurface* surface);
223
224    // enable/disable features
225    void (*enable)(void* c, GGLenum name);
226    void (*disable)(void* c, GGLenum name);
227    void (*enableDisable)(void* c, GGLenum name, GGLboolean en);
228
229    // specify the fragment's color
230    void (*shadeModel)(void* c, GGLenum mode);
231    void (*color4xv)(void* c, const GGLclampx* color);
232    // specify color iterators (16.16)
233    void (*colorGrad12xv)(void* c, const GGLcolor* grad);
234
235    // specify Z coordinate iterators (0.32)
236    void (*zGrad3xv)(void* c, const GGLfixed32* grad);
237
238    // specify W coordinate iterators (16.16)
239    void (*wGrad3xv)(void* c, const GGLfixed* grad);
240
241    // specify fog iterator & color (16.16)
242    void (*fogGrad3xv)(void* c, const GGLfixed* grad);
243    void (*fogColor3xv)(void* c, const GGLclampx* color);
244
245    // specify blending parameters
246    void (*blendFunc)(void* c, GGLenum src, GGLenum dst);
247    void (*blendFuncSeparate)(void* c,  GGLenum src, GGLenum dst,
248                                        GGLenum srcAlpha, GGLenum dstAplha);
249
250    // texture environnement (REPLACE / MODULATE / DECAL / BLEND)
251    void (*texEnvi)(void* c,    GGLenum target,
252                                GGLenum pname,
253                                GGLint param);
254
255    void (*texEnvxv)(void* c, GGLenum target,
256            GGLenum pname, const GGLfixed* params);
257
258    // texture parameters (Wrapping, filter)
259    void (*texParameteri)(void* c,  GGLenum target,
260                                    GGLenum pname,
261                                    GGLint param);
262
263    // texture iterators (16.16)
264    void (*texCoord2i)(void* c, GGLint s, GGLint t);
265    void (*texCoord2x)(void* c, GGLfixed s, GGLfixed t);
266
267    // s, dsdx, dsdy, scale, t, dtdx, dtdy, tscale
268    // This api uses block floating-point for S and T texture coordinates.
269    // All values are given in 16.16, scaled by 'scale'. In other words,
270    // set scale to 0, for 16.16 values.
271    void (*texCoordGradScale8xv)(void* c, GGLint tmu, const int32_t* grad8);
272
273    void (*texGeni)(void* c, GGLenum coord, GGLenum pname, GGLint param);
274
275    // masking
276    void (*colorMask)(void* c,  GGLboolean red,
277                                GGLboolean green,
278                                GGLboolean blue,
279                                GGLboolean alpha);
280
281    void (*depthMask)(void* c, GGLboolean flag);
282
283    void (*stencilMask)(void* c, GGLuint mask);
284
285    // alpha func
286    void (*alphaFuncx)(void* c, GGLenum func, GGLclampx ref);
287
288    // depth func
289    void (*depthFunc)(void* c, GGLenum func);
290
291    // logic op
292    void (*logicOp)(void* c, GGLenum opcode);
293
294    // clear
295    void (*clear)(void* c, GGLbitfield mask);
296    void (*clearColorx)(void* c,
297            GGLclampx r, GGLclampx g, GGLclampx b, GGLclampx a);
298    void (*clearDepthx)(void* c, GGLclampx depth);
299    void (*clearStencil)(void* c, GGLint s);
300
301    // framebuffer operations
302    void (*copyPixels)(void* c, GGLint x, GGLint y,
303            GGLsizei width, GGLsizei height, GGLenum type);
304    void (*rasterPos2x)(void* c, GGLfixed x, GGLfixed y);
305    void (*rasterPos2i)(void* c, GGLint x, GGLint y);
306} GGLContext;
307


Posted by code cat

repo sync로 추가된 저장소를 받아와야 한다.(물론 repo안에 manifest에 새로운 git 저장소에 대한 정보를 추가해야 한다.)

그럼 잘 받아오는데, 문제는 받아온 소스를 수정해서 올릴라고 하니까 branch가 없다고 한다.(당연히 없겠지..)

이럴 땐 새로 받아온 git 저장소 내에서 repo start를 실행하여 branch를 넣어주면 된다.

 

'리눅스 > 스크립트/유틸' 카테고리의 다른 글

python, getopt  (0) 2013.04.21
python, pass statement  (0) 2013.04.17
byobu detached 세션 죽이기  (0) 2013.03.13
grep sed 를 이용해 여러 파일에 있는 문자 치환하기  (0) 2013.02.07
gnu make $(eval)  (0) 2012.11.13
Posted by code cat
책/IT2013. 3. 24. 01:16

 

요새 읽고 있는데, 내용도 쉽고 읽을만한 책인거 같다.

패턴을 다 외울것도 아니고 다 알아야 되는것도 아니라, 중반부터는 필요한 것만 골라 골라 읽는데 괜찮은거 같다. 

난이도도 높지 않아 굳이 C++를 잘 몰라도 읽을 수 있을 정도이다.

' > IT' 카테고리의 다른 글

네트워크 속의 유령, 케빈 미트닉  (0) 2013.12.03
[사고싶은책]64비트 멀티코어OS원리와 구조  (0) 2011.06.27
Posted by code cat

screen -ls | grep "Detached" | awk '{print $1}' | xargs -i screen -X -S {} quit


Posted by code cat

여러 파일에 있는 특정문자를 다른 바꿀문자로 한번에 바꾸는 방법은 다음과 같다.


grep -rl "특정문자" * | xargs sed -i 's/특정문자/바꿀문자/g'


아 편하다...

Posted by code cat