海老原

<< 2010年1月 >>

12
3456789
10111213141516
17181920212223
24252627282930
31

海老原さんの日記

(Web全体に公開)

2010年
01月05日
19:08

コード表示サンプル

PHP


<?php

$modules = array(
'pc' => 'pc_frontend',
'ktai' => 'mobile_frontend',
);

$ds = DIRECTORY_SEPARATOR;

if (!isset($argv[1]) || !realpath($argv[1]))
{
echo 'You must give the OpenPNE2 directory'.PHP_EOL;

exit(1);
}

if (!isset($argv[2]) || !isset($modules[$argv[2]]))
{
echo 'You must give the OpenPNE2 module name'.PHP_EOL;

exit(1);
}

$module = $argv[2];
$path = realpath($argv[1]).$ds.'webapp'.$ds.'modules'.$ds.$module.$ds.'validate'.$ds.'page';

$result = array();

$iterator = new FileSystemIterator($path);
foreach ($iterator as $fileinfo)
{
if (!$fileinfo->isFile())
{
continue;
}

$params = array();
foreach (array_keys(parse_ini_file((string)$fileinfo, true)) as $k)
{
$params[$k] = '';
}

$result['page_'.$fileinfo->getbaseName('.ini')] = array(
'module' => '',
'action' => '',
'params' => $params,
);
}

echo '<?php'.PHP_EOL.'return '.var_export($result, true).';'.PHP_EOL;


shell script

#!/bin/sh

if grep "\(refs\|fixes\) #[0-9]\+" $1 > /dev/null; then
ticket=$(sed -e "s/.*\(fixes\|refs\) #\([0-9]\+\).*/\2/" .git/COMMIT_EDITMSG | line)
title=$(curl -s "http://redmine.openpne.jp/issues/$ticket" | sed -n "/
<title>/p" | sed "s/
<title>\(.\+\)<\/title>/\1/")

if [ "404 - OpenPNE Issue Tracking System" = "$title" ]; then
echo "The specified ticket #$ticket is undefined."
exit 1
fi

echo "This commit will be related to:"
if [ "" != "$title" ]; then
echo $title
else
echo "#$ticket"
fi

exit 0
else
echo "This commit isn't related to any tickets."
exit 1
fi


python

# -*- coding: utf-8 -*-

import xmlrpclib, urllib, urllib2, cookielib, datetime

xmlrpc_url = 'http://user:pass@trac.openpne.jp/login/xmlrpc'
login_url = 'http://redmine.openpne.jp/login'
login_account = {'username': 'user', 'password': 'pass'};
newticket_url = 'http://redmine.openpne.jp/projects/op3/issues/new';

def convert_type(type):
if type == 'defect':
return '1'
elif type == 'enhancement':
return '2'
else:
return '3'

jar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
urllib2.install_opener(opener)

res = urllib2.urlopen(login_url, urllib.urlencode(login_account))

server = xmlrpclib.Server(xmlrpc_url);

for id in server.ticket.query("component=core&status!=closed"):
if id in [4173, 4317, 4319, 3690, 4330, 4325, 3316, 3271, 4316, 4300, 4254, 3309, 4329, 4219, 4066, 4283, 3336]:
continue

ticket = server.ticket.get(id)
data = {
'issue[tracker_id]': convert_type(ticket[3]['type']),
'issue[subject]': ticket[3]['summary'].encode('utf-8'),
'issue[description]': (u"以前のチケットは http://trac.openpne.jp/ticket/"+str(ticket[0])+u" です\n
<pre>"+ticket[3]['description']+"</pre>
").encode('utf-8'),
'issue[status_id]': '1',
'issue[priority_id]': '3',
'issue[assigned_to_id]': '',
'issue[start_date]': datetime.datetime.fromtimestamp(ticket[1]).strftime('%Y-%m-%d'),
'issue[due_date]': '',
'issue[estimated_hours]': '',
'issue[done_ratio]': '0',
}
res = urllib2.urlopen(newticket_url, urllib.urlencode(data))


diff

Index: runkit_methods.c
===================================================================
--- runkit_methods.c (revision 292782)
+++ runkit_methods.c (working copy)
@@ -181,7 +181,7 @@

/* {{{ php_runkit_update_children_methods
Scan the class_table for children of the class just updated */
-int php_runkit_update_children_methods(zend_class_entry *ce, int num_args, va_list args, zend_hash_key *hash_key)
+int php_runkit_update_children_methods(zend_class_entry *ce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
{
zend_class_entry *ancestor_class = va_arg(args, zend_class_entry*);
zend_class_entry *parent_class = va_arg(args, zend_class_entry*);
@@ -190,7 +190,9 @@
char *fname = va_arg(args, char*);
int fname_len = va_arg(args, int);
zend_function *cfe = NULL;
+#if !(PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) && !(PHP_MAJOR_VERSION >= 6)
TSRMLS_FETCH();
+#endif

#ifdef ZEND_ENGINE_2
ce = *((zend_class_entry**)ce);
@@ -210,7 +212,7 @@
}

/* Process children of this child */
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_methods, 5, ancestor_class, ce, fe, fname, fname_len);
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_methods, 5, ancestor_class, ce, fe, fname, fname_len);

PHP_RUNKIT_FUNCTION_ADD_REF(fe);
if (zend_hash_add_or_update(&ce->function_table, fname, fname_len + 1, fe, sizeof(zend_function), NULL, cfe ? HASH_UPDATE : HASH_ADD) == FAILURE) {
@@ -226,7 +228,7 @@

/* {{{ php_runkit_clean_children
Scan the class_table for children of the class just updated */
-int php_runkit_clean_children_methods(zend_class_entry *ce, int num_args, va_list args, zend_hash_key *hash_key)
+int php_runkit_clean_children_methods(zend_class_entry *ce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
{
zend_class_entry *ancestor_class = va_arg(args, zend_class_entry*);
zend_class_entry *parent_class = va_arg(args, zend_class_entry*);
@@ -234,7 +236,9 @@
char *fname = va_arg(args, char*);
int fname_len = va_arg(args, int);
zend_function *cfe = NULL;
+#if !(PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) && !(PHP_MAJOR_VERSION >= 6)
TSRMLS_FETCH();
+#endif

#ifdef ZEND_ENGINE_2
ce = *((zend_class_entry**)ce);
@@ -259,7 +263,7 @@
}

/* Process children of this child */
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, fname, fname_len);
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, fname, fname_len);

zend_hash_del(&ce->function_table, fname, fname_len + 1);

@@ -345,7 +349,7 @@
func.common.fn_flags |= ZEND_ACC_ALLOW_STATIC;
#endif

- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_methods, 5, ancestor_class, ce, &func, methodname,
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_methods, 5, ancestor_class, ce, &func, methodname,
methodname_len);

if (zend_hash_add_or_update(&ce->function_table, methodname, methodname_len + 1, &func, sizeof(zend_function), NULL, add_or_update) == FAILURE) {
@@ -404,7 +408,7 @@

PHP_RUNKIT_ADD_MAGIC_METHOD(dce, dfunc, dfeInHashTable);

- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_methods, 5, dce, dce, &dfe, dfunc, dfunc_len);
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_methods, 5, dce, dce, &dfe, dfunc, dfunc_len);

return SUCCESS;
}
@@ -456,7 +460,7 @@

ancestor_class = php_runkit_locate_scope(ce, fe, methodname, methodname_len);

- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, methodname, methodname_len);
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, methodname, methodname_len);

if (zend_hash_del(&ce->function_table, methodname, methodname_len + 1) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to remove method from class");
@@ -501,7 +505,7 @@
}

ancestor_class = php_runkit_locate_scope(ce, fe, methodname, methodname_len);
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, methodname,
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, methodname,
methodname_len);

func = *fe;

コメント

2010年
01月06日
08:40

1: yoshi

見やすくていいですね

: